Page 1 of 1

mktime != UNIX_TIMESTAMP

Posted: Wed Jan 09, 2008 8:48 am
by anjanesh
mktime(0, 0, 0, 4, 5, 2007); returns 1175731200
but
SELECT UNIX_TIMESTAMP( "2007-04-05" ) returns 1175711400

How come there a difference of 19800 (5.5 hrs) ?

Posted: Wed Jan 09, 2008 9:14 am
by superdezign
It is possible that your database and your server have different times.

Posted: Wed Jan 09, 2008 10:37 am
by RobertGonzalez
That almost certainly the case. Are the two on the same box? Are they using the same default timezone?

Posted: Wed Jan 09, 2008 12:27 pm
by anjanesh
Both are on the same box (my PC) - Using MySQL 5.0.45 and PHP 5.2.5 on Windows XP SP2
Are they using the same default timezone?
How do I check this ?

Posted: Wed Jan 09, 2008 1:15 pm
by RobertGonzalez
I know there is an environment var in *nix for that. PHP has an ini setting in the [date] section. Not sure about MySQL. Their manual may be able to help.

Posted: Wed Jan 09, 2008 1:27 pm
by anjanesh
Ok - this has to be something related to GMT as Indian time is exactly 5.5 hrs ahead of GMT.

my php.ini

Code: Select all

[Date]
; Defines the default timezone used by the date functions
;date.timezone =

;date.default_latitude = 31.7667
;date.default_longitude = 35.2333

;date.sunrise_zenith = 90.583333
;date.sunset_zenith = 90.583333
Nothing related to date in my m.ini file

Posted: Wed Jan 09, 2008 3:00 pm
by RobertGonzalez
Which time is correct? If it is MySQL, then uncomment the php.ini default.timezone setting then add = "{TIMEZONE}" to it where TIMEZONE is one of the timezones listed here.