1TIMEGM(3) Linux Programmer's Manual TIMEGM(3)
2
3
4
6 timegm, timelocal - inverses of gmtime and localtime
7
9 #include <time.h>
10
11 time_t timelocal(struct tm *tm);
12
13 time_t timegm(struct tm *tm);
14
15 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
16
17 timelocal(), timegm():
18 Since glibc 2.19:
19 _DEFAULT_SOURCE
20 Glibc 2.19 and earlier:
21 _BSD_SOURCE || _SVID_SOURCE
22
24 The functions timelocal() and timegm() are the inverses of localtime(3)
25 and gmtime(3). Both functions take a broken-down time and convert it
26 to calendar time (seconds since the Epoch, 1970-01-01 00:00:00 +0000,
27 UTC). The difference between the two functions is that timelocal()
28 takes the local timezone into account when doing the conversion, while
29 timegm() takes the input value to be Coordinated Universal Time (UTC).
30
32 On success, these functions return the calendar time (seconds since the
33 Epoch), expressed as a value of type time_t. On error, they return the
34 value (time_t) -1 and set errno to indicate the cause of the error.
35
37 EOVERFLOW
38 The result cannot be represented.
39
41 For an explanation of the terms used in this section, see
42 attributes(7).
43
44 ┌──────────────────────┬───────────────┬────────────────────┐
45 │Interface │ Attribute │ Value │
46 ├──────────────────────┼───────────────┼────────────────────┤
47 │timelocal(), timegm() │ Thread safety │ MT-Safe env locale │
48 └──────────────────────┴───────────────┴────────────────────┘
50 These functions are nonstandard GNU extensions that are also present on
51 the BSDs. Avoid their use.
52
54 The timelocal() function is equivalent to the POSIX standard function
55 mktime(3). There is no reason to ever use it.
56
58 gmtime(3), localtime(3), mktime(3), tzset(3)
59
61 This page is part of release 4.16 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 2016-12-12 TIMEGM(3)