PHP string to time hour out bug
Tue 12th Apr 2011
If you are using the php function strtotime() and find that the resulting timestamp is not correct then here is the solution
We were writing a simple function that needed the date string in the format "d-m-Y H:i:s" to be converted to a timestamp for processing. For some reason the resulting output was always an hour out. The problem was that the timezone was not specified in the date string.
Bad strtotime input:
strtotime('20-07-1988 12:00:00')
Correct string to time input
strtotime('20-07-1988 12:00:00 GMT')
A simple issue with a simple resolution but one that may not be obvious to spot by using the php strtotime api alone.




