Search code examples
google-calendar-apibootstrap-datetimepicker

how do I format datetimepicker values properly in ISO 8601 Format


I'm kinda stuck here while adding events in google calendar, everything so far has gone in right way except this, when I am inserting a new event using datetimepicker for date and time the google calendar displaying me wrong date and time for the event.

Since, Google Calendar uses ISO 8601 Format so I guess if I can able to convert the date and time I'm getting into ISO 8601 format then my problem would be resolved. Need help from you guys.. Thank you :)


Solution

  • well, finally got my answer my own and it's quite easy to convert just few line of code.

    $tzname=$_POST['tzname'];    
    $endDate = strtotime($endDate);
    $dt= new DateTime("@$endDate");
    $googleEventTime = new DateTimeZone($tzname);
    $googleendevent=$dt->format('c');
    

    then you pass this $googleendevent into google calendar event array. :)