Paul Konstanski
asked on
Convert a GMT TimeStamp to Local Time using PHP
I am doing an API call that gives me a type of timestamp in GMT. For example, it comes in as 2016-11-09T12:18:15+00:00.
I want to convert this to the time of the server running the PHP program which is a GMT -5 and express it YYYY-MM-DD HH:mm:ss
So for the above time how do I convert 2016-11-09T12:18:15+00:00 to 2016-11-09 07:15:15.
Thanks.
I want to convert this to the time of the server running the PHP program which is a GMT -5 and express it YYYY-MM-DD HH:mm:ss
So for the above time how do I convert 2016-11-09T12:18:15+00:00 to 2016-11-09 07:15:15.
Thanks.
ASKER
Sorry I wasn't more clear. I don't want to set the time AS my local server time, I want to convert the API read time to my local time.
This API call happens in batch mode, so it reads four hours worth of data so I can't used the current time. I need to convert the time that comes to me as the GMT format into what the equivalent time was when the record was created.
This API call happens in batch mode, so it reads four hours worth of data so I can't used the current time. I need to convert the time that comes to me as the GMT format into what the equivalent time was when the record was created.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Use strtotime() and date() with the pattern Y-m-d H:i:s
Bookmark these for future reference:
https://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL-Procedural-Version.html
https://www.experts-exchange.com/articles/20920/Handling-Time-and-Date-in-PHP-and-MySQL-OOP-Version.html