I have multiple people uploading log files to my website and the info that is being ingested is time stamps that look like Wed Sep 23 13:07:27 2015
(these can't be changed as they are output by a program I have no control over) I need to convert these into UTC/GMT unix timestamps, I have access to what timezone offset they have (like -05:00
for Central Time) I need to store the timestamps as unix timestamps because they are being displayed on the website with the website having date_default_timezone_set('America/New_York');
set.
This is the ingest code I currently have
strtotime($log["tzoffset"] . ' hours',strtotime($log["orig_time"]))
tzoffset
is the Timezone offset of the user uploading the file -05:00
orig_time
is the timestamp from the file Wed Sep 23 13:07:27 2015
This is the display code
date_default_timezone_set('America/New_York');
date('m-d-Y h:i A', $times["log_time"])
Your problem is here:
strtotime($log["tzoffset"] . ' hours',strtotime($log["orig_time"]));
Where
$log["tzoffset"] = '-05:00';
For some reason strtotime
doesn't work with the :
. You have to send just the -05
. If you can't change the output of your timezone offset, then I would use:
$tz = explode(":", $log["tzoffset"]); strtotime($tz[0] . ' hours',strtotime($log["orig_time"]));