$OpenBSD: time.3,v 1.18 2021/12/11 13:34:38 tb Exp $

Copyright (c) 1989, 1991, 1993
The Regents of the University of California. All rights reserved.

This code is derived from software contributed to Berkeley by
the American National Standards Committee X3, on Information
Processing Systems.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

.Dd $Mdocdate: December 6 2021 $ .Dt TIME 3 .Os .Sh NAME .Nm time .Nd get time of day .Sh SYNOPSIS n time.h .Ft time_t .Fn time "time_t *now" .Sh DESCRIPTION The .Fn time function returns the number of seconds elapsed since Jan 1 1970 00:00:00 UTC. This value is also written to .Fa now unless .Fa now is .Dv NULL . .Sh RETURN VALUES The .Fn time function is always successful, and no return value is reserved to indicate an error. .Sh SEE ALSO .Xr clock_gettime 2 , .Xr gettimeofday 2 , .Xr ctime 3 .Sh STANDARDS The .Fn time function conforms to .St -p1003.1-2008 . .Sh HISTORY A .Fn time system call first appeared in .At v1 . That version counted time in sixtieths of a second with a 32-bit return value, ensuring an integer overflow crisis every 2.26 years. In .At v6 the granularity of the return value was reduced to whole seconds, delaying the aforementioned crisis until 2038. In x 4.1c the function was moved out of the kernel into the C standard library and reimplemented with .Xr gettimeofday 2 .