]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/time.2
PR_*.2const: SYNOPSIS: Some of these calls don't need all args
[thirdparty/man-pages.git] / man2 / time.2
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 2017-09-15 "Linux" "Linux Programmer's Manual"
30 .SH NAME
31 time \- get time in seconds
32 .SH SYNOPSIS
33 .B #include <time.h>
34 .PP
35 .BI "time_t time(time_t *" tloc );
36 .SH DESCRIPTION
37 .BR time ()
38 returns the time as the number of seconds since the
39 Epoch, 1970-01-01 00:00:00 +0000 (UTC).
40 .PP
41 If
42 .I tloc
43 is non-NULL,
44 the return value is also stored in the memory pointed to by
45 .IR tloc .
46 .SH RETURN VALUE
47 On success, the value of time in seconds since the Epoch is returned.
48 On error, \fI((time_t)\ \-1)\fP is returned, and \fIerrno\fP is set
49 appropriately.
50 .SH ERRORS
51 .TP
52 .B EFAULT
53 .I tloc
54 points outside your accessible address space (but see BUGS).
55 .IP
56 On systems where the C library
57 .BR time ()
58 wrapper function invokes an implementation provided by the
59 .BR vdso (7)
60 (so that there is no trap into the kernel),
61 an invalid address may instead trigger a
62 .B SIGSEGV
63 signal.
64 .SH CONFORMING TO
65 SVr4, 4.3BSD, C89, C99, POSIX.1-2001.
66 .\" Under 4.3BSD, this call is obsoleted by
67 .\" .BR gettimeofday (2).
68 POSIX does not specify any error conditions.
69 .SH NOTES
70 POSIX.1 defines
71 .I seconds since the Epoch
72 using a formula that approximates the number of seconds between a
73 specified time and the Epoch.
74 This formula takes account of the facts that
75 all years that are evenly divisible by 4 are leap years,
76 but years that are evenly divisible by 100 are not leap years
77 unless they are also evenly divisible by 400,
78 in which case they are leap years.
79 This value is not the same as the actual number of seconds between the time
80 and the Epoch, because of leap seconds and because system clocks are not
81 required to be synchronized to a standard reference.
82 The intention is that the interpretation of seconds since the Epoch values be
83 consistent; see POSIX.1-2008 Rationale A.4.15 for further rationale.
84 .PP
85 On Linux, a call to
86 .BR time ()
87 with
88 .I tloc
89 specified as NULL cannot fail with the error
90 .BR EOVERFLOW ,
91 even on ABIs where
92 .I time_t
93 is a signed 32-bit integer and the clock ticks past the time 2**31
94 (2038-01-19 03:14:08 UTC, ignoring leap seconds).
95 (POSIX.1 permits, but does not require, the
96 .B EOVERFLOW
97 error in the case where the seconds since the Epoch will not fit in
98 .IR time_t .)
99 Instead, the behavior on Linux is undefined when the system time is out of the
100 .I time_t
101 range.
102 Applications intended to run after 2038 should use ABIs with
103 .I time_t
104 wider than 32 bits.
105 .SH BUGS
106 Error returns from this system call are indistinguishable from
107 successful reports that the time is a few seconds
108 .I before
109 the Epoch, so the C library wrapper function never sets
110 .I errno
111 as a result of this call.
112 .PP
113 The
114 .I tloc
115 argument is obsolescent and should always be NULL in new code.
116 When
117 .I tloc
118 is NULL, the call cannot fail.
119 .\"
120 .SS C library/kernel differences
121 On some architectures, an implementation of
122 .BR time ()
123 is provided in the
124 .BR vdso (7).
125 .SH SEE ALSO
126 .BR date (1),
127 .BR gettimeofday (2),
128 .BR ctime (3),
129 .BR ftime (3),
130 .BR time (7),
131 .BR vdso (7)