C mktime()

« Previous Function Next Function »


The mktime() function returns the calendar-time equivalent of the broken-down time found in the structure pointed to by time. The elements tm_wday and tm_yday are set by the function, so they need not be defined at the time of the call.

If mktime() cannot represent the information as a valid calendar time, -1 is returned.

mktime() Syntax

Following is the syntax of the mktime() function :

time_t mktime(struct tm *time);

mktime() Example

Following program tells you the day fo the week for January 3, 2005 :

void main()
	struct tm t;
	time_t t_of_day;
	t.tm_year = 2005-1900;
	t.tm_mon = 0;
	t.tm_mday = 3;
	t.tm_hour = 0;   /* hour, min, sec don't matter */
	t.tm_min = 0;    /* as long as they don't cause a */
	t.tm_sec = 1;	 /* new day to occur */
	t.tm_isdst = 0;
	t_of_day = mktime(&t);

« Previous Function Next Function »