I am using simplexml_load_file
to parse contains of a trip log file (.GPX
). In it, the tag <time>
records are of the GMT, and I am looking for a PHP funciton or a simple combination of PHP functions to convert it to my local time (GMT+8). I have looked through here and still can not figure out what to do.
To be specific, is there any PHP function which takes in a string like "2013-11-22T04:14:30Z" and returns "2013-11-22 12:14:30" (I wish to display datetime in this format)? I know it can be achieved by writing a function by myself, but I think there could be a standard PHP function that does this.
Pretty easy using
strtotime
&date
:The output would be:
The key for this to work is the
$add_time
which is just me adding+ 8 hours
to the date string. But there are other methods to handle this based on your larger needs & input data.