Time and Date Functions
What are Time, Date Functions in C++?
Explanation
Standard Function Library defines several functions related to
Date and Time. The header file required for the date and time functions is
"<ctime>" or "<time.h>".
This header file defines three time related types
clock_t, time_t and tm. The first two types represent the system time and date as an integer value. But the structure type "tm" holds the date time values individually like second, minute etc. This "ctime" header also defines a macro "CLOCKS_PER_SEC" which is the number of ticks of the system clock per second.
The geopolitical functions are also combined with the time and date function using the header "
<clocale.h>.
Following table lists few Time, Date of C++ Standard function Library.
Name | Description |
asctime | Converts the contents of a structure into the format "day month date hours:minutes:seconds year." |
clock | Returns the amount of time in milliseconds, the calling programm is running. |
ctime | Converts the "time_t" object pointed by the pointer "ptr" to return localtime. |
difftime | |
gmtime | Returns a pointer in the "tm" in broken time format. |
localeconv | |
localtime | Returns a pointer to the broken down time using the "tm" structure. |
mktime | Returns the calendar time equivalent of the broken down structure pointed by "time". |
setlocale | |
strftime | Inserts the time and date, other information into the string pointed by "str", according to the specified format. |
time | Returns the current calendar time of the system. |
The geopolitical functions are also combined with the time and date function using the header "
<clocale.h>.