Solution to mutual conversion between Unix Time Representation and Windows Time Representation

Source: Internet
Author: User

A solution for mutual conversion between Unix Time Representation and Windows Time Representation.

 

Briefly describe the problem: (the above problem can only be implemented in a VC ++ 6.0 or lower development environment. Of course, there may be better solutions for vs2005 and vs2008, But I have limitations in using the development environment .)

1. How to calculate the number of seconds that have elapsed since 00:00:00, January 1, January 1, 1970, and store it in a variable (such as the long type ).

2. How to replace the number of milliseconds stored in a variable (such as the long type) into a systemtime variable relative to 00:00:00, January 1, January 1, 1970.

 

 

Are converted to the relative number of seconds starting from January 1, January 1, 1970.

A. downstream conversion. The time function can be used to obtain the cumulative number of milliseconds from January 1, January 1, 1970.

B. Uplink conversion is more complicated. First, the mktime function is used to calculate the total number of seconds. Second, the time_t type time calculated by the mktime function is converted to the systemtime format.

 

The above solution is a reasonable solution I have found. For more information, see the three articles on msdn: examples (vs.80). aspx and http://msdn.microsoft.com/en-us/library/aa246472 (vs.60). aspx ..

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.