C mktime() function
C mktime() function - Convert broken-down time into time since the Epoch
Syntax:
time_t mktime(struct tm *timeptr)
The mktime() function is used to convert a stored tm structure (assume to be in job local time) pointed to by time, into a time_t structure suitable for use with other time functions.
The fields of the tm structure include:
tm_sec | Seconds (0-61) |
tm_min | Minutes (0-59) |
tm_hour | Hours (0-23) |
tm_mday | Day of month (1-31) |
tm_mon | Month (0-11; January = 0) |
tm_year | Year (current year minus 1900) |
tm_wday | Day of week (0-6; Sunday = 0) |
tm_yday | Day of year (0-365; January 1 = 0) |
tm_isdst | Zero if daylight saving time is not in effect; positive if daylight saving time is in effect; negative if the information is not available. |
Parameters:
Name | Description | Required /Optional |
---|---|---|
timeptr | Pointer to time structure | Required |
Return value from mktime()
- Universal Coordinate Time (UTC) having type time_t.
- The value (time_t)(-1) is returned if the Universal Coordinate Time cannot be represented.
Example: mktime() function
The following example shows the usage of mktime() function.
Output:
It will be a Monday after 110 days and 20 hours from now.
C Programming Code Editor:
Previous C Programming: C localtime()
Next C Programming: C strftime()
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics