ctime Functions & Types
This library contains types and functions to access the date and time.
- The types
- a structure named tm which has the following fields:
- int tm_sec - seconds after the minute (0-61)
- int tm_min - minutes after the hour (0-59)
- int tm_hour - hours since midnight (0-23)
- int tm_mday - day of the month (1-31)
- int tm_mon - months since January (0-11)
- int tm_year - years since 1900
- int tm_wday - days since Sunday (0-6)
- int tm_yday - days since January 1 (0-365)
- bool tm_isdst - is Daylight Savings Time
- a type named time_t which stores an internal representation of the time.
- Some functions
- int clock() - returns the processor time used by the program since the beginning of execution. clock()/CLOCKS_PER_SEC is a time in seconds.
- time_t time(NULL) - returns an internal representation of the current time.
- tm* localtime(const time_t*) - converts the internal time representation to a pointer to a tm structure.
- a sample program using the ctime library to obtain current date and time.
- another sample program using the ctime library to time a piece of code.