#include <time.h> struct tm *gmtime(const time_t *timep);
gmtime
converts a time_t
value to Greenwich Mean Time (GMT),
separates it into components and returns a pointer to a struct tm
containing the results.
gmtime
returns a pointer to the broken-down GMT value. The pointer
may be to static
data, which may remain valid only until the next
call to gmtime
, localtime
, or ctime
.
gmtime
may reference static
storage,
which may be overwritten by the next call to gmtime
, localtime
,
or ctime
.
gmtime
assumes that the value stored in the hardware time-of-day
clock is GMT, as specified by 370 standards. If your site uses the
time-of-day clock for local time, then gmtime
returns local time,
not Greenwich time, and Greenwich time is unavailable.
NULL
is returned if GMT is not available or if the argument value
is not a valid time.
#include <time.h> #include <stdio.h> main () { time_t timeval; struct tm *now; time(&timeval); now = gmtime(&timeval); /* Get current GMT time. */ if (now->tm_mon == 11 && now->tm_mday == 25) puts("Merry Christmas."); }
localtime
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.