Conversion between struct TM and time_t

Source: Internet
Author: User

# Include <stdio. h>
# Include <time. h>
Void main ()
{
Long T;
Time_t S;
Int I;
Short E;
Struct TM * PTM;
E = I = T = Time (null );
PTM = gmtime (& T); // get the address, that is, the parameter is a pointer
Printf ("the return value of time long is: % LD/N", t );
Printf ("the return value of time Int Is: % d/N", I );
Printf ("the return value of time is: % d/N", e );
Printf ("seconds (tm_sec): % d/N", PTM-> tm_sec );
Printf ("minute (tm_min): % d/N", PTM-> tm_min );
Printf ("hour (tm_hour): % d/N", PTM-> tm_hour );
Printf ("Day (tm_mday): % d/N", PTM-> tm_mday );
Printf ("month (tm_mon): 1 + % d/N", PTM-> tm_mon );
Printf ("Year (tm_year): 1900 + % d/N", PTM-> tm_year );
Printf ("Week (tm_wday): % d/N", PTM-> tm_wday );
Printf ("days (tm_yday: % d/N", PTM-> tm_yday );
Printf ("Daylight Saving sign (tm_isdst): % d/N", PTM-> tm_isdst );
S = mktime (PTM); // get the address, that is, the pointer
Printf ("the return value of time is long: % LD/N", S );
}

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.