Javascript new Date (). The role of valueof () and the origin of the time stamp explanation _ Basics

Source: Internet
Author: User
Tags time interval

It is well known that PHP in the time type data can be directly converted to timestamp, then in the front-end script JS, there are methods can be achieved, is valueof ()

For example, we can use this code to output the timestamp of the current point in time

Copy Code code as follows:

<script type= "Text/javascript" >
document.write (New Date (). valueof ());
</script>

So what is the time stamp?

The timestamp is the number of seconds from January 1, 1970 0:0 0 to the current point in time. 1970.1.1 0:0:0 This time is the so-called "time era" in it, I believe you have seen it in many articles. For example, Oracle time display, UNIX and Linux system time calculation, and so why choose 1970, and not choose 1900. Let us then explain its origins.

1. When 32-bit computers are just beginning to rise, the maximum value that the
so-called integer Intger data can represent is:
System.out.println (integer.max_value);
2147483647
2. The total number of seconds for a year 365 is 31536000,
3. Divide between the two, 2147483647/31536000=68.1,
4. That is, 32-bit background, the maximum time interval that can be expressed is 68 years
5. If you count from 1970, you can say that the maximum time is reached 03:14 07 seconds on January 19, 2038, and
6. After this point, all 32-bit operating system time becomes 10000000 00000000 00000000 00000000   is December 13, 1901 20:45 52 seconds, so there is the phenomenon of time regression, some software may be a major anomaly.

To summarize the above points, the person who came up with this set of things, the first is actually those who play Unix, they think that 68 is not long, so starting from 1970 to calculate the 68 years, their hope is that in these 68 years, later people can quickly come up with a better mechanism to change this limit ... Sure enough, the 64-bit rise, put this "doomsday" from
January 19, 2038 03:14 07 seconds--"292,277,026,596 December 4 15:30 08 seconds
So, this number is big enough, computer time" Doomsday " It's really the end of the world.
Code Changes the world, my "source code", My World!

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.