php - Google Calendar API Time

863

When I try to format2015-05-29T19:30:00+08:00 from google calendar api;

return \Carbon\Carbon::createFromTimeStamp(
        strtotime('2015-05-29T19:30:00+08:00')
        );

I get the result2015-05-29 11:30:00 But the start date of the event in my google calendar is exactly07:30PM One thing is that if I try to add a->diffForHumans(); I get the result:

16 minutes ago (Note: the time I run the code is 7:46PM)

Can you help me to understand what is going on in here.

832

Answer

Solution:

Instead of converting the datetime to a unix timestamp, try directly creating a DateTime instance using the original date format which is ISO8601, this should automatically take into account the timezone

return Carbon::createFromFormat(Carbon::ISO8601, '2015-05-29T19:30:00+08:00');

People are also looking for solutions to the problem: Laravel 4.2 - PHP Error reporting turned off

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.