Debian Codegraph @

upstream/debian-unstable/man3/timegm.3

raw
1 '\" t
2 .\" Copyright 2001, Andries E. Brouwer <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH timegm 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 timegm, timelocal \- inverses of gmtime and localtime
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ,\~ \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <time.h>
16 .P
17 .BI "[[deprecated]] time_t timelocal(struct tm *" tm );
18 .BI "time_t timegm(struct tm *" tm );
19 .P
20 .fi
21 .RS -4
22 Feature Test Macro Requirements for glibc (see
23 .BR feature_test_macros (7)):
24 .RE
25 .P
26 .BR timelocal (),
27 .BR timegm ():
28 .nf
29 Since glibc 2.19:
30 _DEFAULT_SOURCE
31 glibc 2.19 and earlier:
32 _BSD_SOURCE || _SVID_SOURCE
33 .fi
34 .SH DESCRIPTION
35 The functions
36 .BR timelocal ()
37 and
38 .BR timegm ()
39 are the inverses of
40 .BR localtime (3)
41 and
42 .BR gmtime (3).
43 Both functions take a broken-down time and convert it to calendar time
44 (seconds since the Epoch, 1970-01-01 00:00:00 +0000, UTC).
45 The difference between the two functions is that
46 .BR timelocal ()
47 takes the local timezone into account when doing the conversion, while
48 .BR timegm ()
49 takes the input value to be Coordinated Universal Time (UTC).
50 .SH RETURN VALUE
51 On success,
52 these functions return the calendar time (seconds since the Epoch),
53 expressed as a value of type
54 .IR time_t .
55 On error, they return the value
56 .I (time_t)\ \-1
57 and set
58 .I errno
59 to indicate the error.
60 .SH ERRORS
61 .TP
62 .B EOVERFLOW
63 The result cannot be represented.
64 .SH ATTRIBUTES
65 For an explanation of the terms used in this section, see
66 .BR attributes (7).
67 .TS
68 allbox;
69 lbx lb lb
70 l l l.
71 Interface Attribute Value
72 T{
73 .na
74 .nh
75 .BR timelocal (),
76 .BR timegm ()
77 T} Thread safety MT-Safe env locale
78 .TE
79 .SH STANDARDS
80 BSD.
81 .SH HISTORY
82 GNU, BSD.
83 .P
84 The
85 .BR timelocal ()
86 function is equivalent to the POSIX standard function
87 .BR mktime (3).
88 There is no reason to ever use it.
89 .SH SEE ALSO
90 .BR gmtime (3),
91 .BR localtime (3),
92 .BR mktime (3),
93 .BR tzset (3)