The role of new date (). valueof () in JavaScript and the origin of the timestamp

Source: Internet
Author: User

Original http://www.cnblogs.com/wshiqtb/archive/2013/04/24/3040116.html

As we all know, in PHP, time data can be directly converted to timestamps, so there are also ways to achieve this in front-end script JS, that is, valueof ()

For exampleCodeOutput The timestamp of the current time point

 
<SCRIPT type ="Text/JavaScript">Document. Write (NewDate (). valueof ());</SCRIPT>

So what is the timestamp?

The timestamp is the number of seconds from 08:00:00, January 1, January 1, 1970 to the current time point. 08:00:00 this time is the so-called "time epoch" in it.ArticleAll of them have seen it. For example, why choose 1970 instead of 1900 for Oracle time display and UNIX and Linux time calculation. Next, let's explain its origins.

1. when a 32-bit computer was just emerging, the so-called integer intger data can represent the maximum value: system. out. println (integer. max_value): 21474836472. the total number of seconds of 365 in a year is 31536000, 3. division of the two, 2147483647/31536000 = 68.1, 4. that is to say, in a 32-bit background, the maximum time interval that can be expressed is 68 years 5. if it is counted from 1970, it indicates that the maximum time will be reached by, January 1, January 19, 2038. after this time point, the time for all 32-bit operating systems will change to 10000000, 00000000, 00000000, or 00000000, that is, 20, 45, and 52 seconds on January 1, December 13, 1901, some software may cause major exceptions. To sum up the above points, the people who come up with this set of things are still the first people who actually play Unix. They considered that the 68 years were not long, so they counted the 68 years from 1970, their hope is that in the past 68 years, people will be able to develop a better mechanism as soon as possible to change this restriction... Indeed, with the rise of 64-bit, this "last day of Time" was taken from, January 19, 2038 to 07 seconds-292,277,026,596-, January 1, December 4. Therefore, this number is big enough, the "end of the world" of computer time is the end of the world. Code changes the world 《 Source code My world!

As we all know, in PHP, time data can be directly converted to timestamps, so there are also ways to achieve this in front-end script JS, that is, valueof ()

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

<SCRIPT type ="Text/JavaScript">Document. Write (NewDate (). valueof ());</SCRIPT>

So what is the timestamp?

The timestamp is the number of seconds from 08:00:00, January 1, January 1, 1970 to the current time point. 08:00:00 this time is the so-called "time epoch" in it. I believe you have seen it in many articles. For example, why choose 1970 instead of 1900 for Oracle time display and UNIX and Linux time calculation. Next, let's explain its origins.

1. when a 32-bit computer was just emerging, the so-called integer intger data can represent the maximum value: system. out. println (integer. max_value): 21474836472. the total number of seconds of 365 in a year is 31536000, 3. division of the two, 2147483647/31536000 = 68.1, 4. that is to say, in a 32-bit background, the maximum time interval that can be expressed is 68 years 5. if it is counted from 1970, it indicates that the maximum time will be reached by, January 1, January 19, 2038. after this time point, the time for all 32-bit operating systems will change to 10000000, 00000000, 00000000, or 00000000, that is, 20, 45, and 52 seconds on January 1, December 13, 1901, some software may cause major exceptions. To sum up the above points, the people who come up with this set of things are still the first people who actually play Unix. They considered that the 68 years were not long, so they counted the 68 years from 1970, their hope is that in the past 68 years, people will be able to develop a better mechanism as soon as possible to change this restriction... Indeed, with the rise of 64-bit, this "last day of Time" was taken from, January 19, 2038 to 07 seconds-292,277,026,596-, January 1, December 4. Therefore, this number is big enough, the "end of the world" of computer time is the end of the world.
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.