Re: Unix date

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The problem is indeed time zones, daylight savings time, etc. Unless your two servers are in the same place you can't really make the times the same without making them wrong in one place. The best thing I can think of to do is specify a timezone, and daylight savings time value, that way you will know what to expect.

You can use the function gmstrtime http://us.php.net/manual/en/function.gmstrftime.php to go from time(assumed GMT) -> unix

Then when you want to get the time of day use gmdate(), it works like date() but gives you the time in GMT, which is what you stored it in so you never have to worry about the local time options.

- Dan

"tedd" <tedd@xxxxxxxxxxxx> wrote in message news:p06240801c39ac223ff5f@[192.168.1.103]...
Hi gang:

Using:

$unix_in = 1255845600;

echo(date("M d, Y h:i:s a",$unix_in));

On one sever, produces: Oct 18, 2009 02:00:00 am

But on another sever, produces: Oct 18, 2009 12:00:00 am

This difference appears to be a combination of "time-zone" and "daylight-savings" considerations. In other words, the function date() looks at the server's time (whatever that is set for, right or wrong) and uses that for the calculation.

So, what's the best method in keeping things consistent across servers? Is there one?

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux