Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>gmtime() convert time from long integer to structure</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 gmtime()                Convert Time from Long Integer to Structure

 #include   <time.h>

 struct     tm *gmtime(time);
 const time_t *time;                     Pointer to stored time

    gmtime() takes a time stored as a long value and converts it to a
    structure representing Greenwich mean time.  The long value 'time'
    can be obtained with a call to 'time'; it is the number of seconds
    since 00:00:00, Jan 1 1970 GMT.

    The structure is of type 'tm', as defined in <time.h>.  The fields of
    structure 'tm' store the following values:

          'tm_sec'        Seconds (0-59)
          'tm_min'        Minutes (0-59)
          'tm_hour'       Hours (0-23)
          'tm_mday'       Day of month (1-31)
          'tm_mon'        Month (0-11; Jan = 0)
          'tm_year'       Year (current year minus 1900)
          'tm_wday'       Day of the week (0-6; Sun = 0)
          'tm_yday'       Day of the year (0-365; Jan 1 = 0)
          'tm_isdst'      Non-zero if daylight saving time, otherwise zero

    Returns:    On success, a pointer to the structure; NULL is returned
                if 'time' is a date before 1980.

      Notes:    Because gmtime(), like localtime(), uses a single
                statically allocated structure to hold the result, a
                subsequent call to the routine destroys the result of the
                previous call.

                DOS does not comprehend dates prior to its birth in 1980.
                For a 'time' representing a date earlier than January 1,
                1980, gmtime() returns 00:00:00, January 1, 1980 if using
                MSC version 4.0, and returns NULL if using MSC version
                5.0 or later.

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

    The following statements get the time stored as a long integer, store
    it in a structure, convert the structure to a character string, and
    print it out.

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

           long elapstime;
           struct tm *greentime;

           main()
           {
               time(&elapstime);
               greentime = gmtime(&elapstime);
               printf("Greenwich time is %s\n",asctime(greentime));
           }


See Also: asctime() ctime() ftime() localtime() time()

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