Time stamp (Unixtimestamp) and "2038 issue"

Source: Internet
Author: User
Tags american time time zones

The timestamp is the total number of seconds from GMT January 01, 1970 00:00 00 seconds (Beijing time January 01, 1970 08:00 00 seconds) to now.

The timestamp is now 10 bits long (1435113975--2015/6/24 10:46:15).

Until 2286/11/21 01:46:40 will not become 11 (10000000000), the distance is now 271 years.

Different time zones to obtain the same times, the generated timestamp will not be the same, such as China is East Eight (+8), the east of the United States is the West Five (-5), the difference between the two places is 13 hours, Beijing than New York 13 hours earlier;

Usually from China's December 15 by plane to the United States, the arrival time is the United States December 15, in China is December 16.

This results in a situation in which the timestamp is not allowed across time zone validation.

So reconcile the dates to the world time.

The Datetime.touniversaltime method in C # will reconcile local time to world time.

Test code:

String date = DateTime.Now.ToString ();//local time
String Dateamerica = DateTime.Now.AddHours (-13). ToString ();//Analog Eastern Time
Object back = (DateTime.Parse (date). ToUniversalTime (). Ticks-621355968000000000)/10000000;//time stamp for coordinated global time
Object Back2 = (datetime.parse (date). Ticks-621355968000000000)/10000000;//time stamp that does not reconcile global time
Object Backa = (DateTime.Parse (dateamerica). Ticks-621355968000000000)/10000000;//simulate time stamp for US Eastern time
Console.WriteLine ("Time:" + date);
Console.WriteLine ("Time stamp of coordinated global time:" + back);
Console.WriteLine ("Type of Timestamp:" + back.) GetType ());
Console.WriteLine ("Length of timestamp:" + back.) ToString (). Length);
Console.WriteLine ("Time stamp for uncoordinated global time:" + Back2);
Console.WriteLine ("Time stamp of the American Time:" + Backa);

Output:

The 2038 issue

On computer applications, the 2038 issue may cause some software to fail to work correctly for 2038 years. All programs that use Unix time to represent time will be affected because they represent time as the number of seconds elapsed since January 1, 1970 (ignoring leap seconds). This time notation is a standard on the Unix-like (unix-like) operating system and affects software developed in its C programming language for use by most other operating systems. On most 32-bit operating systems, this "time_t" data pattern uses a signed 32-bit integer (SIGNEDINT32) to store the number of seconds computed. According to this "time_t" standard, the last time that this format can be represented is January 19, 2038 03:14:07, Tuesday (UTC). Over this instant, the time will be masked (wrap around) and internally expressed as a negative number, and the program will not work because they cannot recognize the time as 2038, and may jump back 1970 or 1901 years depending on the individual implementation. Incorrect calculations and actions may result.

In fact, it is the exception caused by the length overflow on a 32-bit system.

Time stamp (Unixtimestamp) and "2038 issue"

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.