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>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() converts a time, stored as a long value, to a structure. The
    long value 'time' represents the number of seconds that have elapsed
    since 00:00:00, Jan 1 1970.  (This value can be obtained from a call
    to time()). The structure result reflects Greenwich mean time, not
    local time.

    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:     A pointer to the structure result.  There is no error
                    return.

         Notes:     gmtime() and localtime() use a single statically
                    allocated structure to hold the result.  Each call to
                    one of these routines destroys the result of the
                    previous call.

                    MS-DOS does not comprehend dates prior to its birth
                    in 1980. If 'time' represents a date prior to January
                    1, 1980, gmtime() returns 00:00:00, January 1, 1980.

   -------------------------------- 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() localtime() time()

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