1TIMEGM(3)                  Linux Programmer's Manual                 TIMEGM(3)
2
3
4

NAME

6       timegm, timelocal - inverses of gmtime and localtime
7

SYNOPSIS

9       #include <time.h>
10
11       time_t timelocal(struct tm *tm);
12       time_t timegm(struct tm *tm);
13
14   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
15
16       timelocal(), timegm():
17           Since glibc 2.19:
18               _DEFAULT_SOURCE
19           Glibc 2.19 and earlier:
20               _BSD_SOURCE || _SVID_SOURCE
21

DESCRIPTION

23       The functions timelocal() and timegm() are the inverses of localtime(3)
24       and gmtime(3).  Both functions take a broken-down time and  convert  it
25       to  calendar  time (seconds since the Epoch, 1970-01-01 00:00:00 +0000,
26       UTC).  The difference between the two  functions  is  that  timelocal()
27       takes  the local timezone into account when doing the conversion, while
28       timegm() takes the input value to be Coordinated Universal Time (UTC).
29

RETURN VALUE

31       On success, these functions return the calendar time (seconds since the
32       Epoch), expressed as a value of type time_t.  On error, they return the
33       value (time_t) -1 and set errno to indicate the error.
34

ERRORS

36       EOVERFLOW
37              The result cannot be represented.
38

ATTRIBUTES

40       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
41       tributes(7).
42
43       ┌─────────────────────────────────┬───────────────┬────────────────────┐
44Interface                        Attribute     Value              
45       ├─────────────────────────────────┼───────────────┼────────────────────┤
46timelocal(), timegm()            │ Thread safety │ MT-Safe env locale │
47       └─────────────────────────────────┴───────────────┴────────────────────┘
48

CONFORMING TO

50       These functions are nonstandard GNU extensions that are also present on
51       the BSDs.  Avoid their use.
52

NOTES

54       The timelocal() function is equivalent to the POSIX  standard  function
55       mktime(3).  There is no reason to ever use it.
56

SEE ALSO

58       gmtime(3), localtime(3), mktime(3), tzset(3)
59

COLOPHON

61       This  page  is  part of release 5.12 of the Linux man-pages project.  A
62       description of the project, information about reporting bugs,  and  the
63       latest     version     of     this    page,    can    be    found    at
64       https://www.kernel.org/doc/man-pages/.
65
66
67
68GNU                               2021-03-22                         TIMEGM(3)
Impressum