Syntax
#include <time.h> time_t mktime(struct tm *time);Description
mktime converts local time, stored as a tm structure pointed to by time, into a time_t structure suitable for use with other time functions. The values of some structure elements pointed to by time are not restricted to the ranges shown for gmtime.
The values of tm_wday and tm_yday passed to mktime are ignored and are assigned their correct values on return.
Note: The time and date functions begin at 00:00:00 Coordinated Universal Time, January 1, 1970.
mktime returns the calendar time having type time_t. The value (time_t)(-1) is returned if the calendar time cannot be represented.
This example prints the day of the week that is 40 days and 16 hours from the current date.
#include <stdio.h> #include <time.h> char *wday[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" } ; int main(void) { time_t t1,t3; struct tm *t2; t1 = time(NULL); t2 = localtime(&t1); t2->tm_mday += 40; t2->tm_hour += 16; t3 = mktime(t2); printf("40 days and 16 hours from now, it will be a %9s \n", wday[t2->tm_wday ]); return 0; /**************************************************************************** The output should be similar to: 40 days and 16 hours from now, it will be a Sunday ****************************************************************************/ }Related Information