I’m noticing some strange results with date conversions between MYSQL and PHP.
Please see the following
PHP: strtotime(25-Mar-2012) returns 1332626400
Mysql: FROM_UNIXTIME(1332626400) returns 2012-03-25 00:00:00
That results are as expected.
The Problem:
Php: strtotime(26-Mar-2012) returns 1332709200
Mysql: FROM_UNIXTIME(1332709200) returns 2012-03-25 23:00:00
I expect FROM_UNIXTIME to return “2012-03-26” i.e. (March 26 instead of March 25)
Ignoring the time as follows doesn’t help either:
FROM_UNIXTIME(1332709200,’%Y-%m-%d’) returns 2012-03-25
Any idea what’s happening here?
I tried following query on mysql
SELECT FROM_UNIXTIME( 1332709200 ) AS time;
And it returned ‘2012-03-26 02:30:00’.
So it seems something to do with daylight saving or timezone on your server.