seccomp_unotify.2: tfix
[man-pages.git] / man2 / time.2
blobab3d3ecbaccb5a3b665f463b04e90b1af907970f
1 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Modified by Michael Haardt <michael@moria.de>
26 .\" Modified Sat Jul 24 14:13:40 1993 by Rik Faith <faith@cs.unc.edu>
27 .\" Additions by Joseph S. Myers <jsm28@cam.ac.uk>, 970909
28 .\"
29 .TH TIME 2 2021-03-22 "Linux" "Linux Programmer's Manual"
30 .SH NAME
31 time \- get time in seconds
32 .SH SYNOPSIS
33 .nf
34 .B #include <time.h>
35 .PP
36 .BI "time_t time(time_t *" tloc );
37 .fi
38 .SH DESCRIPTION
39 .BR time ()
40 returns the time as the number of seconds since the
41 Epoch, 1970-01-01 00:00:00 +0000 (UTC).
42 .PP
44 .I tloc
45 is non-NULL,
46 the return value is also stored in the memory pointed to by
47 .IR tloc .
48 .SH RETURN VALUE
49 On success, the value of time in seconds since the Epoch is returned.
50 On error, \fI((time_t)\ \-1)\fP is returned, and
51 .I errno
52 is set to indicate the error.
53 .SH ERRORS
54 .TP
55 .B EFAULT
56 .I tloc
57 points outside your accessible address space (but see BUGS).
58 .IP
59 On systems where the C library
60 .BR time ()
61 wrapper function invokes an implementation provided by the
62 .BR vdso (7)
63 (so that there is no trap into the kernel),
64 an invalid address may instead trigger a
65 .B SIGSEGV
66 signal.
67 .SH CONFORMING TO
68 SVr4, 4.3BSD, C89, C99, POSIX.1-2001.
69 .\" Under 4.3BSD, this call is obsoleted by
70 .\" .BR gettimeofday (2).
71 POSIX does not specify any error conditions.
72 .SH NOTES
73 POSIX.1 defines
74 .I seconds since the Epoch
75 using a formula that approximates the number of seconds between a
76 specified time and the Epoch.
77 This formula takes account of the facts that
78 all years that are evenly divisible by 4 are leap years,
79 but years that are evenly divisible by 100 are not leap years
80 unless they are also evenly divisible by 400,
81 in which case they are leap years.
82 This value is not the same as the actual number of seconds between the time
83 and the Epoch, because of leap seconds and because system clocks are not
84 required to be synchronized to a standard reference.
85 The intention is that the interpretation of seconds since the Epoch values be
86 consistent; see POSIX.1-2008 Rationale A.4.15 for further rationale.
87 .PP
88 On Linux, a call to
89 .BR time ()
90 with
91 .I tloc
92 specified as NULL cannot fail with the error
93 .BR EOVERFLOW ,
94 even on ABIs where
95 .I time_t
96 is a signed 32-bit integer and the clock reaches or exceeds 2**31 seconds
97 (2038-01-19 03:14:08 UTC, ignoring leap seconds).
98 (POSIX.1 permits, but does not require, the
99 .B EOVERFLOW
100 error in the case where the seconds since the Epoch will not fit in
101 .IR time_t .)
102 Instead, the behavior on Linux is undefined when the system time is out of the
103 .I time_t
104 range.
105 Applications intended to run after 2038 should use ABIs with
106 .I time_t
107 wider than 32 bits.
108 .SH BUGS
109 Error returns from this system call are indistinguishable from
110 successful reports that the time is a few seconds
111 .I before
112 the Epoch, so the C library wrapper function never sets
113 .I errno
114 as a result of this call.
117 .I tloc
118 argument is obsolescent and should always be NULL in new code.
119 When
120 .I tloc
121 is NULL, the call cannot fail.
123 .SS C library/kernel differences
124 On some architectures, an implementation of
125 .BR time ()
126 is provided in the
127 .BR vdso (7).
128 .SH SEE ALSO
129 .BR date (1),
130 .BR gettimeofday (2),
131 .BR ctime (3),
132 .BR ftime (3),
133 .BR time (7),
134 .BR vdso (7)