phpcalendarrfc2445

How to format date-time for RFC2445 in PHP


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


Solution

  • This is your date format:

    date('Ymd\THis\Z')
    

    becomes

    20150429T154315Z
    

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