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!
== Usage == Unix time is widely adopted in computing beyond its original application as the system time for [[Unix]]. Unix time is available in almost all system programming [[API]]s, including those provided by both Unix-based and non-Unix [[operating systems]]. Almost all modern [[programming languages]] provide APIs for working with Unix time or converting them to another data structure. Unix time is also used as a mechanism for storing timestamps in a number of [[file systems]], [[file formats]], and [[databases]]. The [[C standard library]] uses Unix time for all date and time functions, and Unix time is sometimes referred to as time_t, the name of the [[data type]] used for timestamps in [[C (programming language)|C]] and [[C++]]. C's Unix time functions are defined as the system time API in the [[POSIX]] specification.<ref>{{cite web |title=The Open Group Technical Standard Base Specifications Issue 7 (2018 edition) |url=https://pubs.opengroup.org/onlinepubs/9699919799/functions/time.html |publisher=IEEE and The Open Group |access-date=1 May 2023 |archive-date=1 May 2023 |archive-url=https://web.archive.org/web/20230501172931/https://pubs.opengroup.org/onlinepubs/9699919799/functions/time.html |url-status=live }}</ref> <!-- TODO reword --> The C standard library is used extensively in all modern desktop operating systems, including [[Microsoft Windows]] and [[Unix-like]] systems such as [[macOS]] and [[Linux]], where it is a standard programming interface.<ref name="windows-unix-time">{{cite web |title=time, _time32, _time64 |url=https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/time-time32-time64?view=msvc-170 |website=learn.microsoft.net | date=13 February 2023 |publisher=Microsoft Corporation |access-date=1 May 2023 |archive-date=1 May 2023 |archive-url=https://web.archive.org/web/20230501184037/https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/time-time32-time64?view=msvc-170 |url-status=live }}</ref><ref>{{cite web |title=The GNU C Library (glibc) |url=https://www.gnu.org/software/libc/ |website=The GNU Operating Sisyem |publisher=Free Software Foundation |access-date=1 May 2023 |quote=The GNU C Library project provides the core libraries for the GNU system and GNU/Linux systems, as well as many other systems that use Linux as the kernel. |archive-date=22 April 2016 |archive-url=https://web.archive.org/web/20160422061403/http://www.gnu.org/software/libc/ |url-status=live }}</ref><ref>{{cite web |title=Mac OS X Manual Page for localtime(3) |url=https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/localtime.3.html |website=Apple Documentation Archive |publisher=Apple Inc. |access-date=1 May 2023 |archive-date=22 July 2022 |archive-url=https://web.archive.org/web/20220722085416/https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/localtime.3.html |url-status=live }}</ref> [[iOS]] provides a Swift API which defaults to using an epoch of 1 January 2001 but can also be used with Unix timestamps.<ref>{{cite web |title=NSDate |url=https://developer.apple.com/documentation/foundation/nsdate |website=Apple Developer Documentation |publisher=Apple Inc. |access-date=1 May 2023 |archive-date=1 May 2023 |archive-url=https://web.archive.org/web/20230501172929/https://developer.apple.com/documentation/foundation/nsdate |url-status=live }}</ref> [[Android (operating system)|Android]] uses Unix time alongside a timezone for its system time API.<ref>{{cite web |title=Time Overview |url=https://source.android.com/docs/core/connect/time |website=Android Open Source Project |publisher=Google LLC |access-date=1 May 2023 |archive-date=1 May 2023 |archive-url=https://web.archive.org/web/20230501172931/https://source.android.com/docs/core/connect/time |url-status=live }}</ref> Windows does not use Unix time for storing time internally but does use it in system APIs, which are provided in C++ and implement the C standard library specification.<ref name="windows-unix-time" /> Unix time is used in the [[PE format]] for Windows executables.<ref>{{cite web |title=PE Format - Win32 apps |url=https://learn.microsoft.com/en-us/windows/win32/debug/pe-format |website=learn.microsoft.com |date=24 March 2023 |publisher=Microsoft Corporation |access-date=1 May 2023 |language=en-us |archive-date=29 April 2023 |archive-url=https://web.archive.org/web/20230429214701/https://learn.microsoft.com/en-us/windows/win32/debug/pe-format |url-status=live }}</ref> Unix time is typically available in major programming languages and is widely used in desktop, mobile, and web application programming. [[Java (programming language)|Java]] provides an Instant object which holds a Unix timestamp in both seconds and nanoseconds.<ref>{{cite web |title=Instant (Java Platform SE 8 ) |url=https://docs.oracle.com/javase/8/docs/api/java/time/Instant.html |website=docs.oracle.com |publisher=Oracle |access-date=1 May 2023 |archive-date=25 November 2016 |archive-url=https://web.archive.org/web/20161125045518/http://docs.oracle.com/javase/8/docs/api/java/time/Instant.html |url-status=live }}</ref> [[Python (programming language)|Python]] provides a time library which uses Unix time.<ref>{{citation | url=https://docs.python.org/3/library/time.html | title=time β Time access and conversions | work=Python documentation | accessdate=25 July 2022 | archive-date=22 July 2022 | archive-url=https://web.archive.org/web/20220722022415/https://docs.python.org/3/library/time.html | url-status=live }}</ref> [[JavaScript]] provides a Date library which provides and stores timestamps in milliseconds since the Unix epoch and is implemented in all modern desktop and mobile [[web browsers]] as well as in JavaScript server environments like [[Node.js]].<ref>{{cite web |title=Date - JavaScript {{!}} MDN |url=https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date |website=developer.mozilla.org |publisher=Mozilla |access-date=1 May 2023 |archive-date=21 July 2021 |archive-url=https://web.archive.org/web/20210721082721/https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date |url-status=live }}</ref> [[Free Pascal]] implements UNIX time with the GetTickCount (deprecated unsigned 32 bit) and GetTickCount64 (Unsigned 64 bit) functions to a resolution of 1ms on [[Unix-like]] platforms. Filesystems designed for use with Unix-based operating systems tend to use Unix time. [[APFS]], the file system used by default across all Apple devices, and [[ext4]], which is widely used on Linux and Android devices, both use Unix time in nanoseconds for file timestamps.<ref name="apfs">{{citation|url=https://developer.apple.com/support/downloads/Apple-File-System-Reference.pdf|title=Apple File System Reference|page=57|access-date=19 October 2022|quote=This timestamp is represented as the number of nanoseconds since January 1, 1970 at 0:00 UTC, disregarding leap seconds|archive-date=5 November 2022|archive-url=https://web.archive.org/web/20221105082749/https://developer.apple.com/support/downloads/Apple-File-System-Reference.pdf|url-status=live}}</ref><ref>{{cite web |title=Data Structures and Algorithms |url=https://www.kernel.org/doc/html/v4.19/filesystems/ext4/ondisk/index.html#inode-timestamps |website=The Linux Kernel documentation |publisher=Linux Kernel Organization, Inc. |access-date=1 May 2023 |archive-date=1 May 2023 |archive-url=https://web.archive.org/web/20230501193249/https://www.kernel.org/doc/html/v4.19/filesystems/ext4/ondisk/index.html#inode-timestamps |url-status=live }}</ref> Several [[archive file format|archive file formats]] can store timestamps in Unix time, including [[RAR (file format)|RAR]] and [[tar (computing)|tar]].<ref>{{cite web |title=RAR 5.0 archive format |url=https://www.rarlab.com/technote.htm |website=www.rarlab.com |publisher=win.rar GmbH |access-date=1 May 2023 |quote=Time is stored in Unix time_t format if this flags [sic] is set and in Windows FILETIME format otherwise |archive-date=1 May 2023 |archive-url=https://web.archive.org/web/20230501201914/https://www.rarlab.com/technote.htm |url-status=live }}</ref><ref>{{cite web |title=Tape Archive (tar) File Format Family |url=https://www.loc.gov/preservation/digital/formats/fdd/fdd000531.shtml |website=www.loc.gov |publisher=Library of Congress |access-date=1 May 2023 |date=7 January 2021 |archive-date=1 May 2023 |archive-url=https://web.archive.org/web/20230501201909/https://www.loc.gov/preservation/digital/formats/fdd/fdd000531.shtml |url-status=live }}</ref> Unix time is also commonly used to store timestamps in databases, including in [[MySQL]] and [[PostgreSQL]].<ref name="mysql">{{citation|url=https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html|title=Date and Time Functions|work=MySQL 8.0 Reference Manual|accessdate=19 October 2022|archive-date=19 October 2022|archive-url=https://web.archive.org/web/20221019165011/https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html|url-status=live}}</ref><ref>{{cite web |title=8.5. Date/Time Types |url=https://www.postgresql.org/docs/current/datatype-datetime.html |website=PostgreSQL Documentation |publisher=The PostgreSQL Global Development Group |access-date=1 May 2023 |language=en |date=9 February 2023 |archive-date=1 May 2023 |archive-url=https://web.archive.org/web/20230501123216/https://www.postgresql.org/docs/current/datatype-datetime.html |url-status=live }}</ref>
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)