Debian Codegraph @

upstream/debian-trixie/man2/time.2

raw
1 .\" Copyright (c) 1992 Drew Eckhardt ([email protected]), March 28, 1992
2 .\"
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
4 .\"
5 .\" Modified by Michael Haardt <[email protected]>
6 .\" Modified Sat Jul 24 14:13:40 1993 by Rik Faith <[email protected]>
7 .\" Additions by Joseph S. Myers <[email protected]>, 970909
8 .\"
9 .TH time 2 2024-05-02 "Linux man-pages 6.9.1"
10 .SH NAME
11 time \- get time in seconds
12 .SH LIBRARY
13 Standard C library
14 .RI ( libc ", " \-lc )
15 .SH SYNOPSIS
16 .nf
17 .B #include <time.h>
18 .P
19 .BI "time_t time(time_t *_Nullable " tloc );
20 .fi
21 .SH DESCRIPTION
22 .BR time ()
23 returns the time as the number of seconds since the
24 Epoch, 1970-01-01 00:00:00 +0000 (UTC).
25 .P
26 If
27 .I tloc
28 is non-NULL,
29 the return value is also stored in the memory pointed to by
30 .IR tloc .
31 .SH RETURN VALUE
32 On success, the value of time in seconds since the Epoch is returned.
33 On error, \fI((time_t)\ \-1)\fP is returned, and
34 .I errno
35 is set to indicate the error.
36 .SH ERRORS
37 .TP
38 .B EOVERFLOW
39 The time cannot be represented as a
40 .I time_t
41 value.
42 This can happen if an executable with 32-bit
43 .I time_t
44 is run on a 64-bit kernel when the time is 2038-01-19 03:14:08 UTC or later.
45 However, when the system time is out of
46 .I time_t
47 range in other situations, the behavior is undefined.
48 .TP
49 .B EFAULT
50 .I tloc
51 points outside your accessible address space (but see BUGS).
52 .IP
53 On systems where the C library
54 .BR time ()
55 wrapper function invokes an implementation provided by the
56 .BR vdso (7)
57 (so that there is no trap into the kernel),
58 an invalid address may instead trigger a
59 .B SIGSEGV
60 signal.
61 .SH VERSIONS
62 POSIX.1 defines
63 .I seconds since the Epoch
64 using a formula that approximates the number of seconds between a
65 specified time and the Epoch.
66 This formula takes account of the facts that
67 all years that are evenly divisible by 4 are leap years,
68 but years that are evenly divisible by 100 are not leap years
69 unless they are also evenly divisible by 400,
70 in which case they are leap years.
71 This value is not the same as the actual number of seconds between the time
72 and the Epoch, because of leap seconds and because system clocks are not
73 required to be synchronized to a standard reference.
74 Linux systems normally follow the POSIX requirement
75 that this value ignore leap seconds,
76 so that conforming systems interpret it consistently;
77 see POSIX.1-2018 Rationale A.4.16.
78 .P
79 Applications intended to run after 2038 should use ABIs with
80 .I time_t
81 wider than 32 bits; see
82 .BR time_t (3type).
83 .SS C library/kernel differences
84 On some architectures, an implementation of
85 .BR time ()
86 is provided in the
87 .BR vdso (7).
88 .SH STANDARDS
89 C11, POSIX.1-2008.
90 .SH HISTORY
91 SVr4, 4.3BSD, C89, POSIX.1-2001.
92 .\" Under 4.3BSD, this call is obsoleted by
93 .\" .BR gettimeofday (2).
94 .SH BUGS
95 Error returns from this system call are indistinguishable from
96 successful reports that the time is a few seconds
97 .I before
98 the Epoch, so the C library wrapper function never sets
99 .I errno
100 as a result of this call.
101 .P
102 The
103 .I tloc
104 argument is obsolescent and should always be NULL in new code.
105 When
106 .I tloc
107 is NULL, the call cannot fail.
108 .SH SEE ALSO
109 .BR date (1),
110 .BR gettimeofday (2),
111 .BR ctime (3),
112 .BR ftime (3),
113 .BR time (7),
114 .BR vdso (7)