by Dinesh Thakur Category: Function and Pointer

The prototype of the function is written as given below,

time_t mktime (struct tm * Timeptr) ;

The function converts the broken down time representing local time in the structure pointed to by Timeptr into calendar time. In Program the day of the week is determined; it finds the day of the week on 15th August 2010.

Illustrates mktime () function

#include <stdio.h>

#include <time.h>
int main ()
  time_t T1;
  char *const wday[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
  struct tm Time ;
  Time.tm_year = 2010 - 1900;
  Time.tm_mon = 8 - 1;
  Time.tm_hour = 21;
  Time.tm_min = 41;
  Time.tm_sec = 25;
  Time.tm_isdst = -1;
  Time.tm_mday = 15;
  mktime (&Time);
  printf("The day is %s.\n", wday [Time.tm_wday]);
  printf("%u\n", mktime(&Time));
  printf("%u\n", T1);
  return 0;

Function mktime () in C

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles