Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>mktime() convert time to calendar format</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 mktime()                Convert Time to Calendar Format

 #include   <time.h>                     Required for declarations only

 time_t mktime(my_t);
 struct tm *my_t;       Time to convert

        This function converts the time as stored in a tm structure to
        calendar time (as used by the function time()). If the fields of
        the tm structure are not in their proper ranges, they are
        readjusted.

       Returns:     A time_t structure.

   -------------------------------- Example ---------------------------------

        This example converts 12/25/2000 to calendar time.

 #include <stdio.h>
 #include <time.h>

 int main(void)

    struct tm my_time;
    int year, month, day;

    year = 2000;
    month = 12;
    day = 25;

    my_time.tm_year = year - 1900;
    my_time.tm_mon  = month - 1;
    my_time.tm_mday = day;
    my_time.tm_hour = 0;
    my_time.tm_min  = 0;
    my_time.tm_sec  = 1;
    my_time.tm_isdst = -1;

    mktime(&my_time);   // Convert time.



See Also: localtime() strftime() time()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson