Time stamp in JavaScript

Source: Internet
Author: User

JavaScript gets the current timestamp: The first method: var timestamp = date.parse (new date ()); results: 1280977330000 the second method: var timestamp = (new date ()). ValueOf (); results: 1280977330748 The third method: Var timestamp=new Date (). GetTime (); results: 1280977330748 The first: The time stamp obtained is the change of milliseconds to 000 display, The second and third is to get the timestamp of the current millisecond. Get milliseconds from 1970.1.1!

Why 1970.1.1?

"The following is an explanation of the network transfer"

The first computer operating system is 32 bits, and the time is represented by 32 bits.

System.out.println (Integer.max_value);

2147483647

The Integer is represented in Java in 32 bits, so the maximum value 32 bits can represent is 2147483647. Another 1 years the total number of seconds for 365 days is 31536000,2147483647/31536000 = 68.1, that is, 32 can be expressed as the longest time is 68, starting from 1970, Plus 68.1, the actual final to January 19, 2038 03:14 07 seconds, will reach the maximum time, over this point in time, all 32-bit operating system time will become 10000000 00000000 00000000 00000000, it is December 13, 1901 20:45 52 seconds, so there will be time to return to the phenomenon, a lot of software will run the exception.

Because the maximum interval of 32 bits to represent time is 68, and the earliest Unix operating system takes into account the age of the computer and the time of the application, the time of January 1, 1970 as the era of UNIX times (the start time) is combined. As for the phenomenon of time regression, I believe that with the 64 operating system is gradually resolved, because the 64-bit operating system can be represented to 292,277,026,596 December 4 15:30 08 seconds, believe that our descendants of the nnnn generation, even if the day of the destruction of the earth will not worry enough, Because this time is hundreds of years later.

Time stamp in JavaScript

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.