Problems with the current correct date not being taken

Source: Internet
Author: User
The current correct date problem is not being taken
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.
------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:51
etc/gmt-11 2014-03-07 01:26:51
Etc/gmt-10 2014-03-07 00:26:51
Etc/gmt-9 2014-03-06 23:26:51
Etc/gmt-8 2014-03-06 22:26:51
Etc/gmt-7 2014-03-06 21:26:51
Etc/gmt-6 2014-03-06 20:26:51
Etc/gmt-5 2014-03-06 19:26:51
Etc/gmt-4 2014-03-06 18:26:51
Etc/gmt-3 2014-03-06 17:26:51
Etc/gmt-2 2014-03-06 16:26:51
Etc/gmt-1 2014-03-06 15:26:51
Etc/gmt+0 2014-03-06 14:26:51
Etc/gmt+1 2014-03-06 13:26:51
Etc/gmt+2 2014-03-06 12:26:51
Etc/gmt+3 2014-03-06 11:26:51
Etc/gmt+4 2014-03-06 10:26:51
Etc/gmt+5 2014-03-06 09:26:51
Etc/gmt+6 2014-03-06 08:26:51
Etc/gmt+7 2014-03-06 07:26:51
Etc/gmt+8 2014-03-06 06:26:51
Etc/gmt+9 2014-03-06 05:26:51
Etc/gmt+10 2014-03-06 04:26:51
Etc/gmt+11 2014-03-06 03:26:51
etc/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.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.