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