Page code: Server in United States
Date_default_timezone_set (' PRC '); The time zone is set here
$now _day = Date (' l ');
$now _date = Date ("y/m/d");
echo "Now_day =". $now _day. "
";
echo "now_date =". $now _date. "
";
echo Time ();
echo "
";
Echo Date_default_timezone_get ();
echo "
";
?>
However, the results obtained are as follows:
Now_day =thursday
Now_date =2014/03/06
1394116011
PRC
Always a day less. There is no such situation before, how to do ah.
Reply to discussion (solution)
http://bbs.csdn.net/topics/350031391
Thanks for upstairs, but I can't find a solution.
Disclaimer: No foreign servers, no field testing
But the principle is constant.
Assume that the server's time is accurate
Then there are
$t = 1394116011; The result of Time () for ($i =-12; $i <=12; $i + +) { Date_default_timezone_set (sprintf ("etc/gmt%s%d", $i <0? ": ' + ', $i)) ; Echo Date_default_timezone_get (), date (' y-m-d h:i:s ', $t), Php_eol;}
etc/gmt-12 2014-03-07 02:26:51etc/gmt-11 2014-03-07 01:26:51etc/gmt-10 2014-03-07 00:26:51Etc/GMT-9 2014-03-06 23:26:51etc/gmt-8 2014-03-06 22:26:51etc/gmt-7 2014-03-06 21:26:51etc/gmt-6 2014-03-06 20:26:51Etc/GMT-5 2014-03-06 19:26:51etc/gmt-4 2014-03-06 18:26:51etc/gmt-3 2014-03-06 17:26:51etc/gmt-2 2014-03-06 16:26:51Etc/GMT-1 2014-03-06 15:26:51etc/gmt+0 2014-03-06 14:26:51etc/gmt+1 2014-03-06 13:26:51etc/gmt+2 2014-03-06 12:26:51Etc/GMT+3 2014-03-06 11:26:51etc/gmt+4 2014-03-06 10:26:51etc/gmt+5 2014-03-06 09:26:51etc/gmt+6 2014-03-06 08:26:51Etc/GMT+7 2014-03-06 07:26:51etc/gmt+8 2014-03-06 06:26:51etc/gmt+9 2014-03-06 05:26:51etc/gmt+10 2014-03-06 04:26:51Etc/GMT+11 2014-03-06 03:26:51etc/gmt+12 2014-03-06 02:26:51
You can see that unless you set the time zone in the Pacific, the date will not change in 2014-03-06.
It can be inferred that the time on your server is inaccurate
You can do this manually after a datetime is output by the server default time zone.
Later asked the supplier, they said there should be a problem with the time on the server. Then it was automatically good, and it was estimated that they had made the correct adjustment.