By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,216 Members | 1,032 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,216 IT Pros & Developers. It's quick & easy.

gmdate of a gmmktime time is a day off

P: n/a
I tried running the following script on three different servers:

<?php
echo gmdate('m, d, Y', gmmktime(0,0,0,3,23,2000) );
?>

On two of the servers, I got 03, 23, 2000 back. On the other,
however, I got 03, 22, 2000. This doesn't make any sense to me.

On the servers that return the correct date (03, 23, 2000),
gmmktime(0,0,0,3,23,2000) returns 953769600. On the server that
returns the incorrect date (03, 22, 2000), gmmktime(0,0,0,3,23,2000)
returns 953766000. There's a difference of 3600 between the two,
which makes me think that some daylight savings time setting is to
blame.

I check php.net's entry on gmmktime and see this:

is_dst:
Parameters always represent a GMT date so is_dst doesn't influence
the result.

Thinking I'll try playing around with that setting, all the same, I
find that gmmktime(0,0,0,3,23,2000,1), when ran on the incorrect
server (which is running PHP 4.1.2 on Sun Solaris), gives the correct
answer. gmmktime(0,0,0,3,23,2000,0) gives the wrong answer.

So I try this out on my other servers. On one of the two servers that
was giving the correct answer (and which was running PHP 4.4.3 on some
distro of Linux), gmmktime(0,0,0,3,23,2000,0) gives the correct
answer, and gmmktime(0,0,0,3,23,2000,1) gives the wrong answer.

On the other server (running PHP 4.4.4 on Windows), the last parameter
doesn't make a difference. Again, this behavior is different than any
of the behaviors I've seen, already.

So what do I do?

Feb 13 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.