C Library
C Library
H>
http://www.tutorialspoint.com/c_standard_library/time_h.htm Copyright © tutorialspoint.com
The time.h header defines four variable types, two macro and various functions for manipulating
date and time.
Library Variables
Following are the variable types defined in the header time.h:
1
size_t
This is the unsigned integral type and is the result of the sizeof keyword.
2
clock_t
3
time_t is
4
struct tm
struct tm {
int tm_sec; /* seconds, range 0 to 59 */
int tm_min; /* minutes, range 0 to 59 */
int tm_hour; /* hours, range 0 to 23 */
int tm_mday; /* day of the month, range 1 to 31 */
int tm_mon; /* month, range 0 to 11 */
int tm_year; /* The number of years since 1900 */
int tm_wday; /* day of the week, range 0 to 6 */
int tm_yday; /* day in the year, range 0 to 365 */
int tm_isdst; /* daylight saving time */
};
Library Macros
Following are the macros defined in the header time.h:
1
NULL
Library Functions
Following are the functions defined in the header time.h:
1
char *asctimeconststructtm ∗ timeptr
Returns a pointer to a string which represents the day and time of the structure
timeptr.
2
clock_t clockvoid
Returns the processor clock time used since the beginning of an implementation
defined era normallythebeginningoftheprogram.
3
char *ctimeconsttimet ∗ timer
4
double difftimetimettime1, timettime2
Returns the difference of seconds between time1 and time2 time1 − time2.
5
struct tm *gmtimeconsttimet ∗ timer
The value of timer is broken up into the structure tm and expressed in Coordinated
Universal Time UTC also known as Greenwich Mean Time GMT.
6
struct tm *localtimeconsttimet ∗ timer
The value of timer is broken up into the structure tm and expressed in the local time
zone.
7
time_t mktimestructtm ∗ timeptr
Converts the structure pointed to by timeptr into a time_t value according to the local
time zone.
8
size_t strftimechar ∗ str, sizetmaxsize, constchar ∗ format, conststructtm ∗ timeptr
Formats the time represented in the structure timeptr according to the formatting
rules defined in format and stored into str.
9
time_t timetimet ∗ timer
Calculates the current calender time and encodes it into time_t format.
Loading [MathJax]/jax/output/HTML-CSS/jax.js