The time stamp in C language is used to convert the time string

Source: Internet
Author: User

The time stamp in C language is used to convert the time string

In PE format, a field is the file creation timestamp. I want to convert it into a string, which is more intuitive.

1 1 TCHAR buffer [50] = {0}; 2 2 struct tm Tm = {0}; 3 3 time_t time = (time_t) NtHeader-> FileHeader. timeDateStamp; // timestamp 4 4 gmtime_s (& Tm, & time); 5 5 printf (buffer, TEXT ("% d: % d "), Tm. tm_year + 1900, Tm. tm_mon + 1, Tm. tm_mday, Tm. tm_hour + 8, Tm. tm_min, Tm. tm_sec); 6 6 // Note: The year calculated by this function is the number of years since January 1, 1900, the calculated month 0 indicates that the first month is used for pushing. Therefore, we need to increase the value by 1. The calculated time zone is not in China, and the difference is 8 hours. Therefore, we need to increase the value by 8.

 

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.