Solution: Echo strtotime (' 2013-01-01 11:11:11 ') Different machine results

Source: Internet
Author: User
Tags echo date time zones
The same two lines of code,
 
  "; Echo strtotime ($ts);? >


Running on a Linux server, the result is this:
2013-01-01 11:11:111357009871000

But when I run on this machine, the timestamp is the other one, what's going on?
The time zone on the server is set to "asia/chongqing" and the date output is correct under Linux, which is strange.


Reply to discussion (solution)

You should post the results on two machines separately.

Re-send me my question.
The same Code

 
  "; Echo (Strtotime ($st) *); echo"
"; Echo $ts = (Strtotime ($st) * +)-(Strtotime (' 01-01-1970 00:00:00 ') * 1000);? >


To run the results on a Linux server:
2013-01-01 11:11:1113570098710001357035071000


Running the results on my own machine is different:
2013-01-01 11:11:1113570098710001357038671000


Solve Ah ...

Re-send me my question.
The same Code

 
  "; Echo (Strtotime ($st) *); echo"
"; Echo $ts = (Strtotime ($st) * +)-(Strtotime (' 01-01-1970 00:00:00 ') * 1000);? >


To run the results on a Linux server:
2013-01-01 11:11:1113570098710001357035071000


The results are different on my own local machine: (winxp+wamp2.1)
2013-01-01 11:11:1113570098710001357038671000

Solving..

Are the time zones of the two servers different?
Plus, why multiply by 1000? This date, under PHP is the number of seconds, JS is the number of milliseconds.

Are the time zones of the two servers different?
Plus, why multiply by 1000? This date, under PHP is the number of seconds, JS is the number of milliseconds.

Time zone is the same, *1000 is to turn into JS timestamp

echo Date ("Y-m-d h:i:s", 1357009871);
echo Date ("Y-m-d h:i:s", 1357038671);

2013-01-01 03:11:11
2013-01-01 11:11:11

After eight hours, there must be a problem with the time zone setting.

Reference 4 Floor Luciferstar reply: The time zone of the two servers is different?
Plus, why multiply by 1000? This date, under PHP is the number of seconds, JS is the number of milliseconds.

Time zone is the same, *1000 is to turn into JS timestamp

3,600 seconds, not hard to imagine

echo Date ("Y-m-d h:i:s", 1357009871);
echo Date ("Y-m-d h:i:s", 1357038671);

2013-01-01 03:11:11
2013-01-01 11:11:11

After eight hours, there must be a problem with the time zone setting.

Reference to the 5 floor r9000_com reply: Reference 4 floor Luciferstar ...
This time zone

3,600 seconds, not hard to imagine

It's a 3,600-second difference, but I don't know what caused it.

echo Date ("Y-m-d h:i:s", 1357009871);
echo Date ("Y-m-d h:i:s", 1357038671);

2013-01-01 03:11:11
2013-01-01 11:11:11

After eight hours, there must be a problem with the time zone setting.

Reference to the 5 floor r9000_com reply: Reference 4 floor Luciferstar ...

The comparison should be the two, as this is the result of different results on both machines:

1357038671000

1357035071000

Have found the answer, because the time zone in the php.ini to asia/chongqing and Asia/shanghai, so it will be an hour apart, I changed the php.ini time zone to Asia/shanghai, problem resolution, thank you for answering

  • Related Article

    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.