The current correct date cannot be obtained.

Source: Internet
Author: User
Error page code: server in USA
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 result is:

Now_day = Thursday
Now_date = 2014/03/06
1394116011
PRC


It is always less than one day. This is not the case in the past. how can this problem be solved.


Reply to discussion (solution)

Http://bbs.csdn.net/topics/350031391

Thank you, but no solution is available.

Declare: no foreign servers are available and cannot be tested in the field
But the principle remains unchanged.

Assume that the server time is accurate.
Then there is

$ 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
As you can see, unless you set the time zone on the Pacific Ocean, the date will not change.
So we can infer that the time on your server is not accurate.
In this case, you can manually deduct it after outputting a date by the default time zone of the server.

Later, I asked the supplier that they said there was a problem with the time on the server. Later, it was automatically completed. it was estimated that they were correct.

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.