C language gets current system time

Source: Internet
Author: User

void GetTime () {//Gets the current system time time_t ttime;//the number of seconds from January 1, 1900 char str[80];struct tm* sttim;//time Structure times (&ttime); Sttim = LocalTime (&ttime); Strftime (str,sizeof (str), "%y%m%d%t", sttim);//Format time printf (str);}

Format the time format

%a shorthand for the day of the week

%A full name of the week

%b of the Month

Full name of the%B month

Time string for the date of%c standard

After two digits of the%c year

The day ordinal of a month in%d decimal notation

%d Month/day/year%e in two-character fields, decimal indicates the day ordinal of a month

%F year-month-day

%g two digits of the year, using week-based

%G years, using week-based years

%h Abbreviated month name

%H 24-Hour Hour

%I 12-Hour Hour

%j decimal indicates the day ordinal of the year

%m the month represented by decimal

%M minutes in a 10 o'clock-hour representation

%n New Line character

%p equivalent display of the local AM or PM

%r 12 hours of time

%R display hours and minutes: hh:mm

%s number of seconds in decimal

%t Horizontal Tab

%T display time seconds: hh:mm:ss

%u days of the week, Monday for the first day (values from 0 to 6, Monday to 0)

%u year of the week, the Sunday as the first day (value from 0 to 53)

%V Week of the year, using week-based

%w Decimal Day of the week (value from 0 to 6, Sunday is 0)

%W Week of the year, Monday as the first day (value from 0 to 53)

%x Standard Time string for the date string%x standard

%y decimal Year without century (values from 0 to 99)

%Y 10 year with century part

%z,%z time zone name, cannot assume time zone name or null character.

Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.

C language gets current system time

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.