问题
I know this might sound a silly question, but I did not find in PHP documentation somewhere were they state loud and clear this one.
I have got a web application.
Users of my web appliations are in Europe, but the server running the web appliation is in US.
How should I set the date.timezone php ini directive???
I suppose to where the server is located so if it's in New York: date.timezone = "America/New_York"
But am I right?
回答1:
I think that it's better to set server's local timezone or UTC and change user timezone in script using http://pl.php.net/manual/en/function.date-default-timezone-set.php You can set timezone to Europe/sth or compute it for each client using GeoIP or JavaScript (it should be possible)
回答2:
According to what I read here around on SO the answers is:
- set PHP date.timezone ini directive to "UTC" (i.e. 0)
- let PHP print in pages the date time (UTC) as a simple Unix time stamp (a number)
let Javacscript transform the UTC Unix time stamp in client time by simply doing:
new Date(<?php echo DATE_TIME_SERVER_UTC; ?> * 1000);
回答3:
http://php.net/manual/en/function.date-default-timezone-set.php and How can I easily convert dates from UTC via PHP?
来源:https://stackoverflow.com/questions/2251780/php-ini-date-timezone-server-or-client-location-time-zone