Asctime () |
Time Text Format |
Clock () |
Returns the elapsed time since the program started running |
CTime () |
Return a specific format time |
Difftime () |
The interval between two moments |
Gmtime () |
Returns a pointer to the current GMT point |
LocalTime () |
Returns a pointer to the current time |
Mktime () |
Returns the calendar format for a specified time |
Strftime () |
Returns a single element of a date and time |
Time () |
Returns the current calendar time of the system |
Asctime
Grammar:
#include <time.h> Char *asctime (const struct TM *ptr); |
Function: The function converts the time structure pointed to by PTR into the following string:
Day Month date Hours:minutes:seconds year\n\0
For example:
Mon June 26 12:03:53 2000
Related Topics:
LocalTime (), Gmtime (), Time (), and CTime ().
Clock
Syntax:
#include <time.h> clock_t clock (void); |
Function: The function returns the processor time since the program started running, and returns 1 if no information is available. The conversion return value is in seconds, and the return value is divided by Clocks_per_second. (Note: If the compiler is POSIX-compliant, Clocks_per_second is defined as 1000000.)
Related Topics:
Time (), Asctime (), and CTime ().
CTime
Syntax:
#include <time.h> Char *ctime (const time_t *time); |
Function: The function conversion parameter time is the local temporal format:
Day Month date Hours:minutes:seconds year\n\0
CTime () equivalent
Asctime (localtime (TP));
Related Topics:
LocalTime (), Gmtime (), Time (), and Asctime ().
Difftime
Syntax:
#include <time.h> Double Difftime (time_t time2, time_t time1); |
Function: The function returns the number of seconds that the difference between the time parameter time2 and time1 .
Related Topics:
LocalTime (), Gmtime (), Time (), and Asctime ().
Gmtime
Syntax:
#include <time.h> struct TM *gmtime (const time_t *time); |
Function: The function returns the given uniform world time (usually GMT) if the system does not support the unified world time system to return NULL. Warning!
Related Topics:
LocalTime (), Time (), and Asctime ().
LocalTime
Syntax:
#include <time.h> struct TM *localtime (const time_t *time); |
Function: The function returns the local calendar time. Warning!
Related Topics:
Gmtime (), Time (), and Asctime ().
Mktime
Syntax:
#include <time.h> time_t mktime (struct TM *time); |
Function: The function converts The local time of the type to the time of the calendar and returns the result. If an error occurs, return-1.
Related Topics:
Time (), Gmtime (), Asctime (), and CTime ().
Strftime
Syntax:
#include <time.h> size_t strftime (char *str, size_t maxsize, const char *FMT, struct TM *time); |
Function: The function formats the parameters of the time type as datetime information in the format set by the parameter FMT , and then stores it in the string str (up to maxsize characters). The code used to set the different types of time is:
Code |
Meaning |
%a |
Abbreviated form of the week |
%A |
Full form of the week |
%b |
The abbreviated form of the month |
%B |
Full form of the month |
%c |
The abbreviated form of the month |
%d |
Day ordinal of the month (1-31) |
%H |
Hours, 24-hour format (0-23) |
%I |
Hours, 12-hour format (1-12) |
%j |
Day of the Year (1-366) |
%m |
Month (1-12). Note: Some versions of Microsoft Visual C + + may use a value range of 0-11. |
%M |
Minutes (0-59) |
%p |
Morning or afternoon in local time (AM or PM) |
%s |
Seconds (0-59) |
%u |
Week of the year, Sunday is the first day of the week |
%w |
Numeric representation of the Day of the week (0-6, Sunday =0) |
%W |
Week of the year, Sunday is the first day of the week |
%x |
Standard date string |
%x |
Standard Time string |
%y |
Year (0-99) |
%Y |
Year expressed in Ccyy (eg: 2004) |
%Z |
Time Zone Name |
%% |
Percent Sign |
The function strftime () returns a value of the number of characters in the result string str , and returns zero if an error occurs.
Related Topics:
Time (), localtime (), and Gmtime ().
Time
Syntax:
#include <time.h> time_t time (time_t *time); |
Function: The function returns the current time if an error occurs and returns zero. If a parameter is given, the current time is stored in the parameter.
Related Topics:
LocalTime (), Gmtime (), strftime (), CTime (),
C + + lesson Tenth: standard C time and date functions