Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Unix time
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Representing the number === A Unix time number can be represented in any form capable of representing numbers. In some applications the number is simply represented textually as a string of decimal digits, raising only trivial additional problems. However, certain binary representations of Unix times are particularly significant. The Unix <!-- time_t meaning time type is a C type name. DO NOT REPLACE «time_t» WITH «time t»!!! --><code>[[time_t]]</code><!-- DO NOT REPLACE «time_t» WITH «time t»!!! --> data type that represents a point in time is, on many platforms, a [[Integer (computer science)|signed integer]], traditionally of 32{{nbsp}}[[bit]]s (but [[#Range of representable times|see below]]), directly encoding the Unix time number as described in the preceding section. A signed 32-bit value covers about 68 years before and after the 1970-01-01 epoch. The minimum representable date is Friday 1901-12-13, and the maximum representable date is Tuesday 2038-01-19. One second after 2038-01-19T03:14:07Z this representation will [[arithmetic overflow|overflow]] in what is known as the [[year 2038 problem]]. [[UUID]]v7 encodes the Unix epoch timestamp (in milliseconds) in an unsigned 48-bit field. This representation is valid until the year 10889 AD.<ref> {{IETF RFC|9562}} </ref> In some newer operating systems, <code>time_t</code> has been widened to 64 bits. This expands the times representable to about {{tooltip|1={{round|2^63/365.2422/24/3600/10^9|1}} billion years|2=More precisely, 292277264695 years}}<!-- note:including {{round}} inside {{tooltip}} doesn't work when the resulting number results has an exponent --> in both directions, which is over twenty times the present [[age of the universe]]. There was originally some controversy over whether the Unix <code>time_t</code> should be signed or unsigned. If unsigned, its range in the future would be doubled, postponing the 32-bit overflow (by 68 years). However, it would then be incapable of representing times prior to the epoch. The consensus is for <code>time_t</code> to be signed, and this is the usual practice. The software development platform for version 6 of the [[QNX]] operating system has an unsigned 32-bit <code>time_t</code>, though older releases used a signed type. The [[POSIX]] and [[Open Group]] Unix specifications include the [[C standard library]], which includes the time types and functions defined in the [[time.h|<code><time.h></code>]] header file. The ISO C standard states that <code>time_t</code> must be an arithmetic type, but does not mandate any specific type or encoding for it. POSIX requires <code>time_t</code> to be an integer type, but does not mandate that it be signed or unsigned. Unix has no tradition of directly representing non-integer Unix time numbers as binary fractions. Instead, times with sub-second precision are represented using [[composite data type]]s that consist of two integers, the first being a <code>time_t</code> (the integral part of the Unix time), and the second being the fractional part of the time number in millionths (in <code>struct timeval</code>) or billionths (in <code>struct timespec</code>).<ref>{{cite web |title=timespec |url=https://netbsd.gw.com/cgi-bin/man-cgi?timespec |website=NetBSD Manual Pages |access-date=5 July 2019 |date=12 April 2011 |archive-date=10 August 2019 |archive-url=https://web.archive.org/web/20190810060329/https://netbsd.gw.com/cgi-bin/man-cgi?timespec |url-status=live }}</ref><ref>{{cite web |title=time.h(0P) |url=http://man7.org/linux/man-pages/man0/time.h.0p.html |website=Linux manual page |access-date=5 July 2019 |archive-date=27 June 2019 |archive-url=https://web.archive.org/web/20190627152007/http://man7.org/linux/man-pages/man0/time.h.0p.html |url-status=live }}</ref> These structures provide a [[decimal]]-based [[Fixed-point arithmetic|fixed-point]] data format, which is useful for some applications, and trivial to convert for others.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)