I get log files timestamped using the ISO8601 format from devices in different time zones. Filtering such a file for some values including the timestamp, I could plot certain metrics over time. The issue is the timestamp changes to time zone of the server where the script was run, instead of what is specified in the log file.
Here is an example of what I am doing:
$d = new DateTime();
$d->format('c');
$d->setTimestamp(strtotime("2015-01-19T10:20:24-0500"));
$tz = $d->getTimezone();
echo $tz->getName()."<br/>";
echo $d->format(DateTime::ISO8601)."<br/>";
If I run this script on a server hosted in Australia, the output shows:
Australia/Melbourne
2015-01-20T02:20:24+1100
Instead of GMT-5, the time is shown in GMT+11. Any idea how to retain the time zone from the log file?
Thank you.