1

I am working on Google Calendar API using its PHP library and I need to set a recurring event for which I have to create a RRule string which should be of following format:

RRULE:FREQ=WEEKLY;UNTIL=20110701T170000Z

I am unable to create the date in above format. I literally tried all methods like:

date('YmdHis');
date(DATE_RFC2822);
date('c');

But Google doesn't accept any of above formats. I need to make it like: 20110701T170000Z. Can anybody help me on this?

Thanks

Raja Amer Khan
  • 1,489
  • 10
  • 31

3 Answers3

3

This is your date format:

date('Ymd\THis\Z')

becomes

20150429T154315Z

Look at the examples here: http://php.net/manual/de/function.date.php

Mel_T
  • 451
  • 5
  • 15
2

Are you able to concatenate two strings together and form the required datetime string in RFC2822?

<?php
    $ymd = date('Ymd');
    $hms = date('His');
    echo $ymd."T".$hms."Z"; //Will output YYYYMMDDTHHMMSSZ
?>

Let me know if this works! :)

Ye.
  • 171
  • 12
2

Try this:

date('Ymd\THis\Z', $timestamp);

or

date('Ymd\THis\Z');

if you want the current timestamp

gbestard
  • 1,177
  • 13
  • 29