#include <time.h> struct tm *localtime(const time_t *timep);
localtime
converts a time_t
value to local time, separates it
into components, and returns a pointer to a struct tm
containing
the results.
Under POSIX, localtime
is affected by time-zone information
contained in the TZ environment variable, if it is defined.
localtime
returns a pointer to the broken-down, local-time value.
The pointer may be to static
data, which may remain valid only
until the next call to gmtime
, localtime
, or ctime
.
localtime
may reference static
storage,
which may be overwritten by the next call to gmtime
, localtime
,
or ctime
.
NULL
is returned if local time 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 = localtime(&timeval); /* Get current local time. */ if (now->tm_mon == 0 && now->tm_mday == 1) puts("Happy New Year."); }
gmtime
, tzset
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.