Jump to content

System time: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
fix freq and resolution of PIC
History: updated link
 
(116 intermediate revisions by 53 users not shown)
Line 1: Line 1:
{{Short description|Representation of time used in computers}}
{{Redirect-distinguish|System clock|Clock generator|Clock signal|Clock rate}}
{{Redirect-distinguish|System clock|Clock generator|Clock signal|Clock rate}}
[[Image:System-Time.png|thumb|right|360px|Unix ''[[date (Unix)|date]]'' command]]
[[File:Unix time.png|upright=1.6|thumb|Unix ''[[date (Unix)|date]]'' command]]
In [[computer science]] and [[computer programming]], '''system time''' represents a computer system's notion of the passing of time. In this sense, ''time'' also includes the passing of [[calendar date|days on the calendar]].
In [[computer science]] and [[computer programming]], '''system time''' represents a computer system's notion of the passage of time. In this sense, ''time'' also includes the passing of [[calendar date|days on the calendar]].


System time is measured by a ''system clock'', which is typically implemented as a simple count of the number of ''ticks'' that have transpired since some arbitrary starting date, called the ''[[epoch (reference date)|epoch]]''. For example, [[Unix]] and [[POSIX]]-compliant systems encode system time ("[[Unix time]]") as the number of seconds elapsed since the start of the [[Unix epoch]] at 1 January 1970 00:00:00 [[Universal Time|UT]], with exceptions for [[leap second]]s. Systems that implement the 32-bit and 64-bit versions of the [[Windows API]], such as [[Windows 9x]] and [[Windows NT]], provide the system time as both <tt>SYSTEMTIME</tt>, represented as a year/month/day/hour/minute/second/milliseconds value, and <tt>FILETIME</tt>, represented as a count of the number of 100-nanosecond ticks since 1 January 1601 00:00:00 UT as reckoned in the [[proleptic Gregorian calendar]].
System time is measured by a ''system clock'', which is typically implemented as a simple count of the number of ''ticks'' that have transpired since some arbitrary starting date, called the ''[[epoch (computing)|epoch]]''. For example, [[Unix]] and [[POSIX]]-compliant systems encode system time ("[[Unix time]]") as the number of seconds elapsed since the start of the [[Unix epoch]] at 1 January 1970 00:00:00 [[Universal Time|UT]], with exceptions for [[leap second]]s. Systems that implement the 32-bit and 64-bit versions of the [[Windows API]], such as [[Windows 9x]] and [[Windows NT]], provide the system time as both {{mono|SYSTEMTIME}}, represented as a year/month/day/hour/minute/second/milliseconds value, and {{mono|FILETIME}}, represented as a count of the number of 100-nanosecond ticks since 1 January 1601 00:00:00 UT as reckoned in the [[proleptic Gregorian calendar]].


System time can be converted into [[calendar date|calendar time]], which is a form more suitable for human comprehension. For example, the Unix system [[time_t|time]] ''{{gaps|1|000|000|000}}'' seconds since the beginning of the epoch translates into the calendar time ''9 September 2001 01:46:40 UT''. Library [[subroutines]] that handle such conversions may also deal with adjustments for [[timezones]], [[daylight saving time]] (DST), [[leap seconds]], and the user's [[locale (computer software)|locale]] settings. Library routines are also generally provided that convert calendar times into system times.
System time can be converted into [[calendar date|calendar time]], which is a form more suitable for human comprehension. For example, the [[Unix time|Unix system time]] ''{{gaps|1|000|000|000}}'' seconds since the beginning of the epoch translates into the calendar time ''9 September 2001 01:46:40 UT''. Library [[subroutine]]s that handle such conversions may also deal with adjustments for [[time zone]]s, [[daylight saving time]] (DST), leap seconds, and the user's [[locale (computer software)|locale]] settings. Library routines are also generally provided that convert calendar times into system times.

Many implementations that currently store system times as 32-bit integer values will suffer from the impending [[Year 2038 problem]]. These time values will overflow ("run out of bits") after the end of their system time epoch, leading to [[Time formatting and storage bugs|software and hardware errors]]. These systems will require some form of remediation, similar to efforts required to solve the earlier [[Year 2000 problem]]. This will also be a potentially much larger problem for existing [[file format|data file formats]] that contain system timestamps stored as 32-bit values.


== Other time measurements ==
== Other time measurements ==
Closely related to system time is ''[[process time]]'', which is a count of the total [[CPU]] time consumed by an executing [[process (computing)|process]]. It may be split into ''user'' and ''system'' CPU time, representing the time spent executing user code and system [[kernel (computer science)|kernel]] code, respectively. Process times are a tally of CPU [[instruction cycle|instructions]] or [[clock signal|clock cycles]] and generally have no direct correlation to [[wall time]].
Closely related to system time is ''[[CPU time|process time]]'', which is a count of the total [[Central processing unit|CPU]] time consumed by an executing [[process (computing)|process]]. It may be split into ''user'' and ''system'' CPU time, representing the time spent executing user code and system [[kernel (operating system)|kernel]] code, respectively. Process times are a tally of CPU [[instruction cycle|instructions]] or [[clock signal|clock cycles]] and generally have no direct correlation to [[elapsed real time|wall time]].


[[File system]]s keep track of the times that files are created, modified, and/or accessed by storing [[timestamps]] in the [[file control block]] (or [[inode]]) of each [[computer file|file]] and [[file directory|directory]].
[[File system]]s keep track of the times that files are created, modified, and/or accessed by storing [[timestamp]]s in the [[File Control Block|file control block]] (or [[inode]]) of each [[computer file|file]] and [[directory (computing)|directory]].


== History ==
== History ==
Most first-generation [[personal computer|PCs]] did not keep track of dates and times. These included systems that ran the [[CP/M]] operating system, as well as early models of the [[Apple II]], the [[BBC Micro]] and the [[Commodore PET]], among others. The [[IBM AT]]<!-- and [[IBM XT 286]], [[IBM PS/2]] --> was the first widely available personal computer that came equipped with date/time hardware built into the [[motherboard]]. Add-on [[peripheral|peripheral board]]s that included [[real-time clock]] chips with on-board [[Battery (electricity)|battery back-up]] were also available for the [[IBM PC]] and [[IBM XT|XT]]. Prior to the widespread availability of [[computer network]]s, most personal computer systems that did track system time did so only with respect to local time and did not make allowances for [[time zone]]s.
Most first-generation [[personal computer]]s did not keep track of dates and times. These included systems that ran the [[CP/M]] operating system, as well as early models of the [[Apple II]], the [[BBC Micro]], and the [[Commodore PET]], among others. Add-on [[peripheral|peripheral board]]s that included [[real-time clock]] chips with on-board [[Electric battery|battery back-up]] were available for the [[IBM Personal Computer|IBM PC]] and [[IBM Personal Computer XT|XT]], but the [[IBM Personal Computer AT|IBM AT]] was the first widely available PC that came equipped with date/time hardware built into the [[motherboard]]. Prior to the widespread availability of [[computer network]]s, most personal computer systems that did track system time did so only with respect to [[local time]] and did not make allowances for different [[time zone]]s.


With current technology, most modern computers keep track of local civil time, as do many other household and personal devices such as [[Videocassette recorder|VCR]]s, [[Digital video recorder|DVR]]s, [[Cable television|cable TV receiver]]s, [[Personal digital assistant|PDA]]s, [[pager]]s, [[Mobile phone|cell phone]]s, [[Fax|fax machine]]s, [[answering machine|telephone answering machine]]s, [[camera]]s, [[camcorder]]s, [[Air conditioner|central air conditioner]]s, and [[microwave oven]]s.
With current technology, most modern computers keep track of local civil time, as do many other household and personal devices such as [[Videocassette recorder|VCR]]s, [[Digital video recorder|DVR]]s, [[Cable television|cable TV receiver]]s, [[Personal digital assistant|PDA]]s, [[pager]]s, [[Mobile phone|cell phone]]s, [[Fax|fax machine]]s, [[answering machine|telephone answering machine]]s, [[camera]]s, [[camcorder]]s, [[Air conditioning|central air conditioner]]s, and [[microwave oven]]s.


[[Microcontroller]]s operating within [[embedded system]]s (such as the [[Raspberry Pi]], [[Arduino]], and other [[single-board computer|similar systems]]) do not always have internal hardware to keep track of time. Many such controller systems operate without knowledge of the external time. Those that do require such information typically initialize their base time upon [[reboot (computing)|rebooting]] by obtaining the current time from an external source, such as from a [[time server]] or external clock, or by [[user interface|prompting]] the user to manually enter the current time.
[[Microcontroller]]s operating within [[embedded system]]s (such as the [[Raspberry Pi]], [[Arduino]], and other [[single-board computer|similar systems]]) do not always have internal hardware to keep track of time. Many such controller systems operate without knowledge of the external time. Those that require such information typically initialize their base time upon [[reboot]]ing by obtaining the current time from an external source, such as from a [[time server]] or external clock, or by [[user interface|prompting]] the user to manually enter the current time.


== Implementation ==
== Implementation ==
The '''system clock''' is typically implemented as a [[programmable interval timer]] that periodically interrupts the CPU, which then starts executing a timer interrupt service routine. That routine typically adds one tick to the system clock (a simple counter) and handles other periodic housekeeping tasks ([[preemption (computing)|preemption]], etc.) before returning to whatever the CPU was doing before the interruption.
The '''system clock''' is typically implemented as a [[programmable interval timer]] that periodically interrupts the CPU, which then starts executing a timer interrupt service routine. This routine typically adds one tick to the system clock (a simple counter) and handles other periodic housekeeping tasks ([[preemption (computing)|preemption]], etc.) before returning to the task the CPU was executing before the interruption.


==Retrieving system time==
==Retrieving system time==
Line 32: Line 35:
The following tables illustrate methods for retrieving the system time in various [[operating system]]s, [[programming language]]s, and [[application software|applications]]. Values marked by (*) are system-dependent and may differ across implementations. All dates are given as [[Gregorian calendar|Gregorian]] or [[proleptic Gregorian calendar]] dates.
The following tables illustrate methods for retrieving the system time in various [[operating system]]s, [[programming language]]s, and [[application software|applications]]. Values marked by (*) are system-dependent and may differ across implementations. All dates are given as [[Gregorian calendar|Gregorian]] or [[proleptic Gregorian calendar]] dates.


Note that the [[Orders of magnitude (time)|resolution]] of an implementation's measurement of time does not imply the same [[accuracy]] of such measurements. For example, a system might return the current time as a value measured in microseconds, but actually be capable of discerning individual clock ticks with a frequency of only 100&nbsp;Hz (10&nbsp;ms).
The [[Orders of magnitude (time)|resolution]] of an implementation's measurement of time does not imply the same [[Accuracy and precision|precision]] of such measurements. For example, a system might return the current time as a value measured in microseconds, but actually be capable of discerning individual clock ticks with a frequency of only 100&nbsp;Hz (10&nbsp;ms).


===Operating systems===
===Operating systems===
Line 41: Line 44:
! style="background:#E0E0E0; width:30%" | Command or function
! style="background:#E0E0E0; width:30%" | Command or function
! style="background:#E0E0E0; width:15%" | [[Orders of magnitude (time)|Resolution]]
! style="background:#E0E0E0; width:15%" | [[Orders of magnitude (time)|Resolution]]
! style="background:#E0E0E0; width:30%" | [[Epoch (reference date)|Epoch]] or range
! style="background:#E0E0E0; width:30%" | [[Epoch (computing)|Epoch]] or range
|-
|-
| rowspan="1" |[[Android (operating system)|Android]]
| rowspan="1" |[[Android (operating system)|Android]]
| <tt>java.lang<wbr/>.System.currentTimeMillis()</tt>
| {{code|java.lang}}<wbr/>{{code|.System.currentTimeMillis()}}
| rowspan="1" |1 ms
| rowspan="1" |1 ms
| rowspan="1" |1 January 1970
| rowspan="1" |1 January 1970
|-
|-
| rowspan="3" |[[BIOS]] ([[IBM Personal Computer|IBM PC]])
| rowspan="3" |[[BIOS]] ([[IBM Personal Computer|IBM PC]])
| <tt>INT 1Ah, AH=00h</tt><ref>[[Ralf D. Brown]], "Int 0x1A, AH=0x00" in [[Ralf Brown's Interrupt List]], 2000, http://www.delorie.com/djgpp/doc/rbinter/ix/1A/00.html</ref>
| {{code|1=INT 1Ah, AH=00h}}<ref>{{cite web|author=Ralf D. Brown|author-link=Ralf D. Brown|title=Int 0x1A, AH=0x00|work=[[Ralf Brown's Interrupt List]]|date=2000|url=http://www.delorie.com/djgpp/doc/rbinter/ix/1A/00.html}}</ref>
| 54.9254 ms<br /> 18.2065&nbsp;Hz <!-- <br> 2<sup>16</sup> ticks/hr -->
| 54.9254 ms<br /> 18.2065&nbsp;Hz <!-- <br /> 2<sup>16</sup> ticks/hr -->
| Midnight of the current day
| Midnight of the current day
|-
|-
| <tt>INT 1Ah, AH=02h</tt><ref>[[Ralf D. Brown]], "Int 0x1A, AH=0x02" in [[Ralf Brown's Interrupt List]], 2000, http://www.delorie.com/djgpp/doc/rbinter/ix/1A/02.html</ref><!--<br> or reading CMOS regs.-->
| {{code|1=INT 1Ah, AH=02h}}<ref>{{cite web|author=Ralf D. Brown|author-link=Ralf D. Brown|title=Int 0x1A, AH=0x02|work=[[Ralf Brown's Interrupt List]]|date=2000|url=http://www.delorie.com/djgpp/doc/rbinter/ix/1A/02.html}}</ref><!--<br /> or reading CMOS regs.-->
| 1 s
| 1 s
| Midnight of the current day
| Midnight of the current day
|-
|-
| <tt>INT 1Ah, AH=04h</tt><ref>[[Ralf D. Brown]], "Int 0x1A, AH=0x04" in [[Ralf Brown's Interrupt List]], 2000, http://www.delorie.com/djgpp/doc/rbinter/ix/1A/04.html</ref><!--<br> or reading CMOS regs.-->
| {{code|1=INT 1Ah, AH=04h}}<ref>{{cite web|author=Ralf D. Brown|author-link=Ralf D. Brown|title=Int 0x1A, AH=0x04|work=[[Ralf Brown's Interrupt List]]|date=2000|url=http://www.delorie.com/djgpp/doc/rbinter/ix/1A/04.html}}</ref><!--<br /> or reading CMOS regs.-->
| 1 day
| 1 day
| 1 January 1980 to 31 December 1999 or 31 December 2079 (system dependent)
| 1 January 1980 to 31 December 1999 or 31 December 2079 (system dependent)
|-
|-
| rowspan="2" | [[CP/M Plus]]
| rowspan="2" | [[CP/M Plus]]
| System Control Block:<ref>{{cite web |url=http://www.cpm.z80.de/manuals/cpm3-sys.pdf |title=CP/M Plus (CP/M Version 3.0) Operating System Guide}}</ref><br/> <tt>scb$base+58h</tt>, Days since 1 Jan 1978<br/> <tt>scb$base+5Ah</tt>, Hour (BCD)<br/> <tt>scb$base+5Bh</tt>, Minute (BCD)<br/> <tt>scb$base+5Ch</tt>, Second (BCD)<br/>
| System Control Block:<ref>{{cite web |url=http://www.cpm.z80.de/manuals/cpm3-sys.pdf |title=CP/M Plus (CP/M Version 3.0) Operating System Guide}}</ref><br/> {{code|scb$base+58h}}, Days since 31 December 1977<br/> {{code|scb$base+5Ah}}, Hour (BCD)<br/> {{code|scb$base+5Bh}}, Minute (BCD)<br/> {{code|scb$base+5Ch}}, Second (BCD)<br/>
| rowspan="2" | 1 s
| rowspan="2" | 1 s
| rowspan="2" | 1 January 1978 to September 2067
| rowspan="2" | 31 December 1977 to 5 June 2157
|-
|-
| BDOS function <tt>69h</tt> (<tt>T_GET</tt>):<ref>{{cite web |url=http://www.seasip.info/Cpm/bdos.html#105 |title=BDOS system calls}}</ref><br/> <tt>word</tt>, Days since 1 January 1978<br/> <tt>byte</tt>, Hour (BCD)<br/> <tt>byte</tt>, Minute (BCD)<br /> <tt>byte</tt>, Second (BCD)
| BDOS function {{code|69h}}> ({{code|T_GET}}):<ref>{{cite web |url=http://www.seasip.info/Cpm/bdos.html#105 |title=BDOS system calls}}</ref><br/> {{code|word}}, Days since 1 January 1978<br/> {{code|byte}}, Hour (BCD)<br/> {{code|byte}}, Minute (BCD)<br /> {{code|byte}}, Second (BCD)
|-
|-
| rowspan="2" | [[DOS]] ([[Microsoft]])
| rowspan="2" | [[DOS]] ([[Microsoft]])
| <tt>{{samp|C:\>}}[[DATE (command)|DATE]]<br/>{{samp|C:\>}}[[TIME (command)|TIME]]</tt>
| {{code|C:\>}} [[DATE (command)|{{code|DATE}}]]<br/>{{code|C:\>}} [[TIME (command)|{{code|TIME}}]]
| rowspan="2" | 10 ms<!-- DL returns 1/100 of a second, so '''resolution''' is 10 ms; though accuracy is 55 ms. Also the [[FAT filesystem]] stores timestamps with 2 s resolution, except for create date, which is stored in 10 ms -->
| rowspan="2" | 10 ms<!-- DL returns 1/100 of a second, so '''resolution''' is 10 ms; though accuracy is 55 ms. Also the [[FAT filesystem]] stores timestamps with 2 s resolution, except for create date, which is stored in 10 ms -->
| rowspan="2" | 1 January 1980 to 31 December 2099
| rowspan="2" | 1 January 1980 to 31 December 2099
|-
|-
| <tt>INT 21h, AH=2Ch SYSTEM TIME</tt><ref>[[Ralf D. Brown]], "Int 0x21, AH=0x2c" in [[Ralf Brown's Interrupt List]], 2000, http://www.delorie.com/djgpp/doc/rbinter/ix/21/2C.html</ref></tt><br/><tt>INT 21h, AH=2Ah SYSTEM DATE</tt><ref>[[Ralf D. Brown]], "Int 0x21, AH=0x2a" in [[Ralf Brown's Interrupt List]], 2000, http://www.delorie.com/djgpp/doc/rbinter/ix/21/2A.html</ref></tt>
| {{code|1=INT 21h, AH=2Ch SYSTEM TIME}}<ref>{{cite web|author=Ralf D. Brown|author-link=Ralf D. Brown|title=Int 0x21, AH=0x2c|work=[[Ralf Brown's Interrupt List]]|date=2000|url=http://www.delorie.com/djgpp/doc/rbinter/ix/21/2C.html}}</ref><br/>{{code|1=INT 21h, AH=2Ah SYSTEM DATE}}<ref>{{cite web|author=Ralf D. Brown|author-link=Ralf D. Brown|title=Int 0x21, AH=0x2a|work=[[Ralf Brown's Interrupt List]]|date=2000|url=http://www.delorie.com/djgpp/doc/rbinter/ix/21/2A.html}}</ref>
|-
|-
| [[iOS]] ([[Apple Computer|Apple]])
| [[iOS]] ([[Apple Inc.|Apple]])
| <tt>CFAbsoluteTimeGetCurrent()</tt><ref>[https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFTimeUtils/Reference/reference.html#//apple_ref/doc/c_ref/CFAbsoluteTimeGetCurrent "Time Utilities Reference"] in ''iOS Developer Library'' (Apple, 2007).</ref>
| {{code|CFAbsoluteTimeGetCurrent()}}<ref>{{cite web|url=https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFTimeUtils/Reference/reference.html#//apple_ref/doc/c_ref/CFAbsoluteTimeGetCurrent|title=Time Utilities Reference|work=iOS Developer Library|date=2007}}</ref>
| < 1 ms
| < 1 ms
| 1 January 2001 ±10,000 years
| 1 January 2001 ±10,000 years
|-
|-
| [[macOS]]
| [[Mac OS]] ([[Apple Computer|Apple]])
| <tt>CFAbsoluteTimeGetCurrent()</tt><ref>[https://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFTimeUtils/Reference/reference.html "Time Utilities Reference"] in ''Mac OS X Developer Library'' (Apple, 2007).</ref>
| {{code|CFAbsoluteTimeGetCurrent()}}<ref>{{cite web|url=https://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFTimeUtils/Reference/reference.html|title=Time Utilities Reference|work=Mac OS X Developer Library|date=2007}}</ref>
| < 1 ms<ref name="Apple_CFRunLoopTimerCreate">[https://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFRunLoopTimerRef/Reference/reference.html#apple_ref/c/func/CFRunLoopTimerCreate "CFRunLoopTimer Reference"] in ''Mac OS X Developer Library'' (Apple, 2007).</ref><ref group="note" name="Apple_CF_NSTimeInterval">The Apple Developer Documentation is not clear on the precision & range of CFAbsoluteTime/CFTimeInterval, except in the CFRunLoopTimerCreate documentation which refers to 'sub-millisecond at most' precision. However, the similar type [https://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/Reference/reference.html#apple_ref/c/tdef/NSTimeInterval NSTimeInterval] appears to be interchangeable, and has the precision and range listed.</ref>
| < 1 ms<ref name="Apple_CFRunLoopTimerCreate">{{cite web |title=Time Utilities - Foundation |url=https://developer.apple.com/documentation/corefoundation/time_utilities |access-date=6 July 2022 |work=Apple Developer Documentation}}</ref><ref group="note" name="Apple_CF_NSTimeInterval">The Apple Developer Documentation is not clear on the precision & range of CFAbsoluteTime/CFTimeInterval, except in the CFRunLoopTimerCreate documentation which refers to 'sub-millisecond at most' precision. However, the similar type [https://developer.apple.com/documentation/foundation/nstimeinterval NSTimeInterval] appears to be interchangeable, and has the precision and range listed.</ref>
| 1 January 2001 ±10,000 years<ref name="Apple_CFRunLoopTimerCreate"/><ref group="note" name="Apple_CF_NSTimeInterval"/>
| 1 January 2001 ±10,000 years<ref name="Apple_CFRunLoopTimerCreate"/><ref group="note" name="Apple_CF_NSTimeInterval"/>
|-
|-
| [[OpenVMS]] ([[Hewlett Packard|HP]])
| rowspan="3" |[[OpenVMS]]
| <tt>SYS$GETTIM()</tt>
| {{code|SYS$GETTIM()}}
| 100 ns<ref name="idsm-5.2">{{cite book|title=VAX/VMS Internals and Data Structures, Version 5.2|url=https://books.google.com/books?id=D7xQAAAAMAAJ|isbn=978-1555580599|author1=Ruth E. Goldenberg|author2=Lawrence J. Kenah|author3=Denise E. Dumas|publisher=Digital Press|date=1991}}</ref>
| 100 ns
| [[Julian day#Alternatives|17 November 1858]] to 31 July 31,086<ref name = "Crazy time, Stanford, 1997">{{Cite web | url = https://www.slac.stanford.edu/~rkj/crazytime.txt | title = Why is Wednesday, November 17, 1858 the base time for OpenVMS (VAX VMS)? | access-date = 2020-01-08 | date = 1997-07-24 | website = [[Stanford University]] | archive-url = https://web.archive.org/web/19970724202734/https://www.slac.stanford.edu/~rkj/crazytime.txt | archive-date = 1997-07-24 | df = dmy-all | url-status = live}}</ref>
| [[Julian day#Alternatives|17 November 1858]] to AD 31,086
|-
|-
| <span class="plainlinks">{{man|sh|gettimeofday|SUS||inline}}()</span>
| [[z/OS]] ([[IBM]])
| 1 [[Microsecond|μs]]<ref name="vsi-c-rtl">{{cite web|url=https://vmssoftware.com/docs/VSI_CRTL_REF.pdf|title=VSI C Run-Time Library Reference Manual for OpenVMS Systems|date=November 2020|publisher=VSI|access-date=2021-04-17}}</ref>
| <tt>STCK</tt><ref>[http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/download/A2278325.pdf?DT=20070807125005&XKS=DZ9ZBK07 ''z/Architecture Principles of Operation''] (Poughkeepsie, New York:International Business Machines, 2007) 7-187.</ref>
| rowspan="2" |1 January 1970 to 7 February 2106<ref>{{cite web|url=https://www.zx.net.nz/mirror/h71000.www7.hp.com/2038.html|title=OpenVMS and the year 2038|publisher=HP|access-date=2021-04-17}}</ref>
| 2<sup>&minus;12</sup> μs<br /> 244.14 ps<ref>[http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/download/A2278325.pdf?DT=20070807125005&XKS=DZ9ZBK07 ''z/Architecture Principles of Operation''], (Poughkeepsie, New York:International Business Machines, 2000) 4-45, 4-46.</ref>
|-
| <span class="plainlinks">{{man|sh|clock_gettime|SUS||inline}}()</span>
| 1 [[Nanosecond|ns]]<ref name="vsi-c-rtl" />
|-
| rowspan="2" | [[z/OS]]
| {{code|STCK}}<ref name="z-architecture">{{cite book|url=http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/download/A2278325.pdf?DT=20070807125005&XKS=DZ9ZBK07|title=z/Architecture Principles of Operation|location=Poughkeepsie, New York|publisher=International Business Machines|date=2007}}</ref>{{rp|7–187}}
| rowspan="2"|2<sup>&minus;12</sup> μs<br /> 244.14 ps<ref name="z-architecture"/>{{rp|4-45, 4-46}}
| 1 January 1900 to 17 September 2042 UT<ref>IBM intends to extend the date range on future systems beyond 2042. [http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/download/A2278325.pdf?DT=20070807125005&XKS=DZ9ZBK07 ''z/Architecture Principles of Operation''], (Poughkeepsie, New York:International Business Machines, 2007) 1-15, 4-45 to 4-47.</ref>
| 1 January 1900 to 17 September 2042 UT<ref>IBM intends to extend the date range on future systems beyond 2042. [http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/download/A2278325.pdf?DT=20070807125005&XKS=DZ9ZBK07 ''z/Architecture Principles of Operation''], (Poughkeepsie, New York:International Business Machines, 2007) 1-15, 4-45 to 4-47.</ref>
|-
| {{code|STCKE}}
| 1 January 1900 to AD 36,765<ref>{{cite web|url=https://www.ibm.com/docs/en/zos/2.4.0?topic=addressing-expanded-64-bit-time-values|title=Expanded 64-bit time values|publisher=IBM|access-date=2021-04-18}}</ref>
|-
|-
| rowspan="3" | [[Unix]], [[POSIX]]<br/> (see also [[C date and time functions]])
| rowspan="3" | [[Unix]], [[POSIX]]<br/> (see also [[C date and time functions]])
| <tt>{{samp|$}}[[date (Unix)|date]]</tt><br /><tt>[[time()]]</tt>
| {{samp|$}}[[date (Unix)|{{code|date}}]]<br/>[[time()|{{code|time()}}]]
| 1 s
| 1 s
| rowspan="3" |(*)<br/> 1 January 1970 to [[Year 2038 problem|19 January 2038]]<br/> 1 January 1970 to AD 292,277,026,596
| rowspan="3" |(*)<br/> 1 January 1970 (to [[Year 2038 problem|19 January 2038]] prior to Linux 5.9) to 2 July 2486 (Since Linux 5.10)<br/>1 January 1970 to 4 December AD 292,277,026,596
|-
|-
| <tt><span class="plainlinks">{{man|sh|gettimeofday|SUS||inline}}()</span></tt>
| <span class="plainlinks">{{man|sh|gettimeofday|SUS||inline}}()</span>
| 1 [[Microsecond|μs]]
| 1 [[Microsecond|μs]]
|-
|-
| <tt><span class="plainlinks">{{man|sh|clock_gettime|SUS||inline}}()</span></tt>
| <span class="plainlinks">{{man|sh|clock_gettime|SUS||inline}}()</span>
| 1 ns
| 1 ns
|-
|-
| [[OS/2]]
| rowspan="2" | [[Microsoft Windows|Windows]] ([[Microsoft]])
| {{code|DosGetDateTime()}}
| <tt>GetSystemTime()</tt>
| 10 ms
| 1 January 1980 to 31 December 2079<ref>{{cite web|quote=On OS/2 Warp 4, date and time can both operate well beyond the year 2000, and even well beyond the year 2038, and in fact up to the year 2079, which is the limit for OS/2 Warp 4's real-time clock.|url=https://jdebp.eu/Softwares/cmd.html|title=The 32-bit Command Interpreter|author=Jonathan de Boyne Pollard}}</ref>
|-
| rowspan="3" | [[Microsoft Windows|Windows]]
| {{code|GetSystemTime()}}
| 1 ms
| 1 ms
| rowspan="2" |1 January 1601 to AD 30,828
| rowspan="3" |1 January 1601 to 14 September 30828, 02:48:05.4775807
|-
| {{code|GetSystemTimeAsFileTime()}}
| rowspan="2" | 100 ns
|-
|-
| {{code|GetSystemTimePreciseAsFileTime()}}
| <tt>GetSystemTimeAsFileTime()</tt>
| 100 ns
|}
|}


Line 122: Line 142:
! style="background:#E0E0E0; width:30%" |Function or variable
! style="background:#E0E0E0; width:30%" |Function or variable
! style="background:#E0E0E0; width:15%" |[[Orders of magnitude (time)|Resolution]]
! style="background:#E0E0E0; width:15%" |[[Orders of magnitude (time)|Resolution]]
! style="background:#E0E0E0; width:30%" |[[Epoch (reference date)|Epoch]] or range
! style="background:#E0E0E0; width:30%" |[[Epoch (computing)|Epoch]] or range
|-
|-
| [[Ada (programming language)|Ada]]
| [[Ada (programming language)|Ada]]
| <tt>Ada.Calendar.Clock</tt>
| {{code|Ada.Calendar.Clock}}
| 100 μs to<br/> 20 ms (*)
| 100 μs to<br/> 20 ms (*)
| 1 January 1901 to 31 December 2099 (*)
| 1 January 1901 to 31 December 2099 (*)
|-
|-
| [[AWK]]
| [[AWK]]
| <tt>systime()</tt>
| {{code|systime()}}
| 1 s
| 1 s
| (*)
| (*)
|-
|-
| [[BASIC]], [[True BASIC]]
| [[BASIC]], [[True BASIC]]
| <tt>DATE</tt>, <tt>DATE$</tt><br /> <tt>TIME</tt>, <tt>TIME$</tt>
| {{code|DATE}}, {{code|DATE$}}<br /> {{code|TIME}}, {{code|TIME$}}
| 1 s
| 1 s
| (*)
| (*)
|-
|-
| [[Business BASIC]]
| [[Business BASIC]]
| <tt>DAY</tt>, <tt>TIM</tt>
| {{code|DAY}}, {{code|TIM}}
| 0.1 s
| 0.1 s
| (*)
| (*)
|-
|-
| [[C (programming language)|C]] (see [[C date and time functions]])
| [[C (programming language)|C]] (see [[C date and time functions]])
| <tt>[[time()]]</tt>
| [[time()|{{code|time()}}]]
| 1 s (*)<ref group="note" name="stdC">The [[C standard library]] does not specify any specific resolution, epoch, range, or datatype for [[time_t|system time values]]. The C++ library encompasses the C library, so it uses the same system time implementation as C.</ref>
| 1 s (*)<ref group="note" name="stdC">The [[C standard library]] does not specify any specific resolution, epoch, range, or datatype for [[time_t|system time values]]. The C++ library encompasses the C library, so it uses the same system time implementation as C.</ref>
| (*)<ref group="note" name="stdC"></ref>
| (*)<ref group="note" name="stdC"></ref>
|-
|-
| [[C++]]
| [[C++]]
| <tt>std::time()</tt> <br/> <tt>std::chrono::system_clock::now()</tt>
| {{code|std::time()}} <br/> {{code|std::chrono::system_clock::now()}}
| 1 s (*)<ref group="note" name="stdC"></ref><br/>1 ns (C++11, OS dependent)
| 1 s (*)<ref group="note" name="stdC"></ref><br/>1 ns (C++11, OS dependent)
| (*)<ref group="note" name="stdC"></ref>
| (*)<ref group="note" name="stdC"></ref>
|-
|-
| [[C Sharp (programming language)|C#]] ([[Microsoft]])
| [[C Sharp (programming language)|C#]]
| <tt>System.DateTime.Now</tt><ref name="ms-datetime">[http://msdn.microsoft.com/en-us/library/system.datetime.now.aspx "DateTime.Now Property"] in ''[[MSDN]]'' (Microsoft, 2010) last updated July 2010.</ref><br/> <tt>System.DateTime.UtcNow</tt><ref name="ms-utcnow">[http://msdn.microsoft.com/en-us/library/system.datetime.utcnow.aspx "DateTime.UtcNow Property"] in ''MSDN'' (Microsoft, 2011)</ref>
| {{code|System.DateTime.Now}}<ref name="ms-datetime">{{cite web|url=https://docs.microsoft.com/en-us/dotnet/api/system.datetime.now|title=DateTime.Now Property|website=Microsoft Docs}}</ref><br/> {{code|System.DateTime.UtcNow}}<ref name="ms-utcnow">{{cite web|url=https://docs.microsoft.com/en-us/dotnet/api/system.datetime.utcnow|title=DateTime.UtcNow Property|website=Microsoft Docs}}</ref>
| 100 ns<ref name="dotnet">[http://msdn.microsoft.com/en-us/library/system.datetime.ticks.aspx "DateTime.Ticks Property] in ''MSDN'' (Microsoft, 2010) last updated May 2010.</ref>
| 100 ns<ref name="dotnet">{{cite web|url=https://docs.microsoft.com/en-us/dotnet/api/system.datetime.ticks|title=DateTime.Ticks Property|website=Microsoft Docs}}</ref>
| 1 January 0001 to 31 December 9999
| 1 January 0001 to 31 December 9999
|-
|-
| [[CICS]] ([[IBM]])
| [[CICS]]
| <tt>ASKTIME</tt>
| {{code|ASKTIME}}
| 1 ms
| 1 ms
| 1 January 1900
| 1 January 1900
|-
|-
| [[COBOL]]
| [[COBOL]]
| <tt>FUNCTION CURRENT-DATE</tt>
| {{code|FUNCTION CURRENT-DATE}}
| 1 s
| 1 s
| 1 January 1601
| 1 January 1601
|-
|-
| [[Common Lisp]]
| [[Common Lisp]]
| <tt>(get-universal-time)</tt>
| {{code|(get-universal-time)}}
| 1 s
| 1 s
| 1 January 1900
| 1 January 1900
|-
|-
| [[Borland Delphi|Delphi]] ([[Borland]])
| [[Delphi (software)|Delphi]] ([[Borland]])
| <tt>date</tt><br/><tt>time</tt>
| {{code|date}}<br/>{{code|time}}
| 1 ms<br/> (floating point)
| 1 ms<br/> (floating point)
| 1 January 1900
| 1 January 1900
|-
|-
| rowspan="9" | [[Embarcadero Delphi|Delphi]]<br/> ([[Embarcadero Technologies]])<ref name="embarcadero-docwiki-datetime-support">[http://docwiki.embarcadero.com/RADStudio/XE4/en/Date_and_Time_Support "Date and Time Support"] in ''Embarcadero Developer Network'' (Embarcadero Technologies, 2013)</ref>
| rowspan="9" | [[Delphi (software)|Delphi]]<br/> ([[Embarcadero Technologies]])<ref name="embarcadero-docwiki-datetime-support">{{cite web|url=http://docwiki.embarcadero.com/RADStudio/XE4/en/Date_and_Time_Support|title=Date and Time Support|website=Embarcadero Developer Network|date=2013}}</ref>
| <tt>System.SysUtils.Time</tt><ref name="embarcadero-docwiki-time">[http://docwiki.embarcadero.com/Libraries/XE4/en/System.SysUtils.Time "System.SysUtils.Time"] in ''Embarcadero Developer Network'' (Embarcadero Technologies, 2013)</ref>
| {{code|System.SysUtils.Time}}<ref name="embarcadero-docwiki-time">{{cite web|url=http://docwiki.embarcadero.com/Libraries/XE4/en/System.SysUtils.Time|title=System.SysUtils.Time|website=Embarcadero Developer Network|date=2013}}</ref>
| rowspan="6" | 1 ms
| rowspan="6" | 1 ms
| rowspan="2" | 0/0/0000 0:0:0:000 to 12/31/9999 23:59:59:999 [sic]
| rowspan="2" | 0/0/0000 0:0:0:000 to<br/>12/31/9999 23:59:59:999 [sic]
|-
|-
| <tt>System.SysUtils.GetTime</tt><ref name="embarcadero-docwiki-gettime">[http://docwiki.embarcadero.com/Libraries/XE4/en/System.SysUtils.GetTime "System.SysUtils.GetTime"] in ''Embarcadero Developer Network'' (Embarcadero Technologies, 2013)</ref> (alias for <tt>System.SysUtils.Time</tt>)
| {{code|System.SysUtils.GetTime}}<ref name="embarcadero-docwiki-gettime">{{cite web|url=http://docwiki.embarcadero.com/Libraries/XE4/en/System.SysUtils.GetTime|title=System.SysUtils.GetTime|website=Embarcadero Developer Network|date=2013}}</ref> (alias for {{code|System.SysUtils.Time}})
|-
|-
| <tt>System.SysUtils.Date</tt><ref name="embarcadero-docwiki-date">[http://docwiki.embarcadero.com/Libraries/XE4/en/System.SysUtils.Date "System.SysUtils.Date"] in ''Embarcadero Developer Network'' (Embarcadero Technologies, 2013)</ref>
| {{code|System.SysUtils.Date}}<ref name="embarcadero-docwiki-date">{{cite web|url=http://docwiki.embarcadero.com/Libraries/XE4/en/System.SysUtils.Date|title=System.SysUtils.Date|website=Embarcadero Developer Network'|date=2013}}</ref>
| rowspan="4" | 0/0/0000 0:0:0:000 to 12/31/9999 0:0:0:000 [sic]
| rowspan="4" | 0/0/0000 0:0:0:000 to<br/>12/31/9999 0:0:0:000 [sic]
|-
|-
| <tt>System.DateUtils.Today</tt><ref name="embarcadero-docwiki-today">[http://docwiki.embarcadero.com/Libraries/XE4/en/System.DateUtils.Today "System.DateUtils.Today"] in ''Embarcadero Developer Network'' (Embarcadero Technologies, 2013)</ref>
| {{code|System.DateUtils.Today}}<ref name="embarcadero-docwiki-today">{{cite web|url=http://docwiki.embarcadero.com/Libraries/XE4/en/System.DateUtils.Today|title=System.DateUtils.Today|website=Embarcadero Developer Network|date=2013}}</ref>
|-
|-
| <tt>System.DateUtils.Tomorrow</tt><ref name="embarcadero-docwiki-tomorrow">[http://docwiki.embarcadero.com/Libraries/XE4/en/System.DateUtils.Tomorrow "System.DateUtils.Tomorrow"] in ''Embarcadero Developer Network'' (Embarcadero Technologies, 2013)</ref>
| {{code|System.DateUtils.Tomorrow}}<ref name="embarcadero-docwiki-tomorrow">{{cite web|url=http://docwiki.embarcadero.com/Libraries/XE4/en/System.DateUtils.Tomorrow|title=System.DateUtils.Tomorrow|website=Embarcadero Developer Network|date=2013}}</ref>
|-
|-
| <tt>System.DateUtils.Yesterday</tt><ref name="embarcadero-docwiki-yesterday">[http://docwiki.embarcadero.com/Libraries/XE4/en/System.DateUtils.Yesterday "System.DateUtils.Yesterday"] in ''Embarcadero Developer Network'' (Embarcadero Technologies, 2013)</ref>
| {{code|System.DateUtils.Yesterday}}<ref name="embarcadero-docwiki-yesterday">{{cite web|url=http://docwiki.embarcadero.com/Libraries/XE4/en/System.DateUtils.Yesterday|title=System.DateUtils.Yesterday|website=Embarcadero Developer Network|date=2013}}</ref>
|-
|-
| <tt>System.SysUtils.Now</tt><ref name="embarcadero-docwiki-now">[http://docwiki.embarcadero.com/Libraries/XE4/en/System.SysUtils.Now "System.SysUtils.Now"] in ''Embarcadero Developer Network'' (Embarcadero Technologies, 2013)</ref>
| {{code|System.SysUtils.Now}}<ref name="embarcadero-docwiki-now">{{cite web|url=http://docwiki.embarcadero.com/Libraries/XE4/en/System.SysUtils.Now|title=System.SysUtils.Now|website=Embarcadero Developer Network|date=2013}}</ref>
| 1 s
| 1 s
| 0/0/0000 0:0:0:000 to 12/31/9999 23:59:59:000 [sic]
| 0/0/0000 0:0:0:000 to<br/>12/31/9999 23:59:59:000 [sic]
|-
|-
| <tt>System.SysUtils.DayOfWeek</tt><ref name="embarcadero-docwiki-dayofweek">[http://docwiki.embarcadero.com/Libraries/XE4/en/System.SysUtils.DayOfWeek "System.SysUtils.DayOfWeek"] in ''Embarcadero Developer Network'' (Embarcadero Technologies, 2013)</ref>
| {{code|System.SysUtils.DayOfWeek}}<ref name="embarcadero-docwiki-dayofweek">{{cite web|url=http://docwiki.embarcadero.com/Libraries/XE4/en/System.SysUtils.DayOfWeek|title=System.SysUtils.DayOfWeek|website=Embarcadero Developer Network|date=2013}}</ref>
| 1 day
| 1 day
| 1 to 7
| 1 to 7
|-
|-
| <tt>System.SysUtils.CurrentYear</tt><ref name="embarcadero-docwiki-currentyear">[http://docwiki.embarcadero.com/Libraries/XE4/en/System.SysUtils.CurrentYear "System.SysUtils.CurrentYear"] in ''Embarcadero Developer Network'' (Embarcadero Technologies, 2013)</ref>
| {{code|System.SysUtils.CurrentYear}}<ref name="embarcadero-docwiki-currentyear">{{cite web|url=http://docwiki.embarcadero.com/Libraries/XE4/en/System.SysUtils.CurrentYear|title=System.SysUtils.CurrentYear|website=Embarcadero Developer Network|date=2013}}</ref>
| 1 year
| 1 year
| (*)
| (*)
|-
|-
| [[Emacs Lisp]]
| [[Emacs Lisp]]
| <tt>(current-time)</tt>
| {{code|(current-time)}}
| 1 μs (*)
| 1 μs (*)
| 1 January 1970
| 1 January 1970
|-
|-
| [[Erlang (programming language)|Erlang]] ([[Ericsson]])
| [[Erlang (programming language)|Erlang]]
| <tt>[http://erlang.org/doc/man/erlang.html#system_time-0 erlang:system_time()]</tt>, <tt>[http://erlang.org/doc/man/os.html#system_time-0 os:system_time()]</tt><ref name="Erlang">[http://erlang.org/doc/apps/erts/time_correction.html Time and Time Correction in Erlang]</ref>
| [http://erlang.org/doc/man/erlang.html#system_time-0 {{code|erlang:system_time()}}], [http://erlang.org/doc/man/os.html#system_time-0 {{code|os:system_time()}}]<ref name="Erlang">{{cite web|url=https://www.erlang.org/doc/apps/erts/time_correction.html|title=Time and Time Correction in Erlang|website=www.erlang.org}}</ref>
| [[Operating system|OS]] dependent, e.g. on [[Linux]] 1ns<ref name="Erlang" />
| [[Operating system|OS]] dependent, e.g. on [[Linux]] 1ns<ref name="Erlang" />
| 1 January 1970<ref name="Erlang" />
| 1 January 1970<ref name="Erlang" />
|-
|-
| [[Microsoft Excel|Excel]] ([[Microsoft]])
| [[Microsoft Excel|Excel]]
| <tt>date()</tt>
| {{code|date()}}
| ?
| ?
| [[January 0|0 January]] 1900<ref name="m">"In the Microsoft Office Spreadsheet Component, the value 0 evaluates to the date December 30, 1899 and the value 1 evaluates to December 31, 1899. ... In Excel, the value 0 evaluates to January 0, 1900 and the value 1 evaluates to January 1, 1900." [http://support.microsoft.com/kb/205719 XL2000: Early Dates on Office Spreadsheet Component Differ from Excel] in (''Microsoft Support'', 2003).</ref>
| [[January 0|0 January]] 1900<ref name="m">{{cite web|quote=In the Microsoft Office Spreadsheet Component, the value 0 evaluates to the date December 30, 1899 and the value 1 evaluates to December 31, 1899. ... In Excel, the value 0 evaluates to January 0, 1900 and the value 1 evaluates to January 1, 1900.|url=http://support.microsoft.com/kb/205719|title=XL2000: Early Dates on Office Spreadsheet Component Differ from Excel|website=Microsoft Support|date=2003|archive-url=https://web.archive.org/web/20071024010448/http://support.microsoft.com/kb/205719|archive-date=24 October 2007}}</ref>
|-
|-
| rowspan="2" | [[Fortran]]
| rowspan="2" | [[Fortran]]
| <tt>DATE_AND_TIME</tt><br/> <tt>SYSTEM_CLOCK</tt>
| {{code|DATE_AND_TIME}}<br/> {{code|SYSTEM_CLOCK}}
| (*)<ref name="fortran1">[http://software.intel.com/sites/products/documentation/hpc/compilerpro/en-us/fortran/lin/compiler_f/lref_for/source_files/rfsystmc.htm "SYSTEM_CLOCK"], documentation for FORTRAN compiler, Intel Corp., accessed 27 October 2011.</ref>
| (*)<ref name="fortran1">{{cite web|url=https://software.intel.com/en-us/fortran-compiler-developer-guide-and-reference-system-clock|title=SYSTEM_CLOCK|work=Intel Fortran Compiler 19.0 Developer Guide and Reference|date=29 April 2019|access-date=23 July 2019}}</ref>
<ref name="fortran2">[https://gcc.gnu.org/onlinedocs/gfortran/SYSTEM_005fCLOCK.html SYSTEM_CLOCK — Time function"] in ''The GNU Fortran Compiler'' (Free Software Foundation) accessed 27 October 2011.</ref>
<ref name="fortran2">{{cite web|url=https://gcc.gnu.org/onlinedocs/gfortran/SYSTEM_005fCLOCK.html|title=SYSTEM_CLOCK — Time function|work=The GNU Fortran Compiler|access-date=27 October 2011}}</ref>
| rowspan="2" | 1 January 1970
| rowspan="2" | 1 January 1970
|-
|-
| <tt>CPU_TIME</tt>
| {{code|CPU_TIME}}
| 1 μs
| 1 μs
|-
|-
| [[Go (programming language)|Go]]
| [[Go (programming language)|Go]]
| <tt>time.Now()</tt>
| {{code|time.Now()}}
| 1 ns
| 1 ns
| 1 January 0001
| 1 January 0001
|-
|-
| rowspan="2" | [[Haskell (programming language)|Haskell]]
| rowspan="2" | [[Haskell]]
| <tt>Time.getClockTime</tt>
| {{code|Time.getClockTime}}
| 1 ps (*)
| 1 ps (*)
| 1 January 1970 (*)
| 1 January 1970 (*)
|-
|-
| <tt>Data.Time.getCurrentTime</tt>
| {{code|Data.Time.getCurrentTime}}
| 1 ps (*)
| 1 ps (*)
| 17 November 1858 (*)
| 17 November 1858 (*)
|-
|-
| rowspan="3" | {{anchor|java}} [[Java (Sun)|Java]] ([[Sun Microsystems|Sun]])
| rowspan="3" | {{anchor|java}} [[Java (software platform)|Java]]
| <tt>java.util.Date()</tt><br/><tt>System.currentTimeMillis()</tt>
| {{code|java.util.Date()}}<br/>{{code|System.currentTimeMillis()}}
| 1 ms
| 1 ms
| 1 January 1970
| 1 January 1970
|-
|-
| <tt>System.nanoTime()</tt><ref name="sunJavaNanoTime">[http://java.sun.com/javase/6/docs/enwiki/api/java/lang/System.html#nanoTime() System.nanoTime() method] in ''Java Platform, Standard Edition 6: API Specification'' (Oracle, 2011) accessed 27 October 2011.</ref>
| {{code|System.nanoTime()}}<ref name="sunJavaNanoTime">{{cite web|url=https://docs.oracle.com/javase/6/docs/enwiki/api/java/lang/System.html#nanoTime()|title=System.nanoTime() method|work=Java Platform, Standard Edition 6: API Specification|date=2015|access-date=23 July 2019}}</ref>
| 1 ns
| 1 ns
| arbitrary<ref name="sunJavaNanoTime" />
| arbitrary<ref name="sunJavaNanoTime" />
|-
|-
| <tt>Clock.systemUTC()</tt><ref name="sunJavaClock">[https://docs.oracle.com/javase/8/docs/enwiki/api/java/time/Clock.html#systemUTC-- Clock.systemUTC() and other methods] in ''Java Platform, Standard Edition 8: API Specification'' (Oracle, 2014) accessed 15 January 2015.</ref>
| {{code|Clock.systemUTC()}}<ref name="sunJavaClock">{{cite web|url=https://docs.oracle.com/javase/8/docs/enwiki/api/java/time/Clock.html#systemUTC--|title=Clock.systemUTC() and other methods|work=Java Platform, Standard Edition 8: API Specification|date=2014|access-date=15 January 2015}}</ref>
| 1 ns
| 1 ns
| arbitrary<ref name="sunInstant">[https://docs.oracle.com/javase/8/docs/enwiki/api/java/time/Instant.html JSR-310 Java Time System] in ''Java Platform, Standard Edition 8: API Specification'' (Oracle, 2014) accessed 15 January 2015.</ref>
| arbitrary<ref name="sunInstant">{{cite web|url=https://docs.oracle.com/javase/8/docs/enwiki/api/java/time/Instant.html|title=JSR-310 Java Time System|work=Java Platform, Standard Edition 8: API Specification|date=2014|access-date=15 January 2015}}</ref>
|-
|-
| [[JavaScript]]
| [[JavaScript]], [[TypeScript]]
| <tt>(new Date()).getTime()</tt><br/> <tt>Date.now()</tt>
| {{code|(new Date()).getTime()}}<br/> {{code|Date.now()}}
| 1 ms
| 1 ms
| 1 January 1970
| 1 January 1970
|-
|-
| [[Matlab]]
| [[Matlab]]
| <tt>now</tt>
| {{code|now}}
| 1 s
| 1 s
| 0 January 0000<ref>[http://www.mathworks.com/help/matlab/ref/datenum.html] Matlab Help</ref>
| 0 January 0000<ref>{{cite web|url=http://www.mathworks.com/help/matlab/ref/datenum.html|title=Matlab Help}}</ref>
|-
|-
| [[MUMPS]]
| [[MUMPS]]
| <tt>$H</tt> (''short for'' <tt>[[Horology|$HOROLOG]]</tt>)
| {{code|$H}} (''short for'' [[Horology|{{code|$HOROLOG}}]])
| 1 s
| 1 s
| 31 December 1840
| 31 December 1840
|-
|-
| rowspan="2" | [[LabVIEW]]
| rowspan="2" | [[LabVIEW]]
| <tt>Tick Count</tt>
| {{code|Tick Count}}
| 1 ms
| 1 ms
| 00:00:00.000 1 January 1904
| 00:00:00.000 1 January 1904
|-
|-
| <tt>Get Date/Time in Seconds</tt>
| {{code|Get Date/Time in Seconds}}
| 1 ms
| 1 ms
| 00:00:00.000 1 January 1904
| 00:00:00.000 1 January 1904
Line 284: Line 304:


| [[Objective-C]]
| [[Objective-C]]
| <tt>[NSDate timeIntervalSinceReferenceDate]</tt>
| {{code|[NSDate timeIntervalSinceReferenceDate]}}
| < 1 ms<ref name="Apple_NSTimeInterval">[https://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/Reference/reference.html#apple_ref/c/tdef/NSTimeInterval "Foundation Data Types Reference"] in ''Mac OS X Developer Library'' (Apple, 2011) last modified 6 July 2011, section NSTimeInterval.</ref>
| < 1 ms<ref name="Apple_NSTimeInterval">{{cite web|url=https://developer.apple.com/documentation/foundation/nstimeinterval|work=Apple Developer Documentation|title=NSTimeInterval - Foundation}}</ref>
| 1 January 2001 ±10,000 Years<ref name="Apple_NSTimeInterval"/>
| 1 January 2001 ±10,000 Years<ref name="Apple_NSTimeInterval"/>
|-
|-
| rowspan="2" | [[OCaml]]
| rowspan="2" | [[OCaml]]
| <tt>Unix.time()</tt>
| {{code|Unix.time()}}
| 1 s
| 1 s
| rowspan="2" | 1 January 1970
| rowspan="2" | 1 January 1970
|-
|-
| <tt>Unix.gettimeofday()</tt>
| {{code|Unix.gettimeofday()}}
| 1 μs
| 1 μs
|-
|-
| [[Pascal (programming language)|Extended Pascal]]<!--(ISO/IEC 10206:1990)-->
| [[Pascal (programming language)|Extended Pascal]]<!--(ISO/IEC 10206:1990)-->
| <tt>GetTimeStamp()</tt>
| {{code|GetTimeStamp()}}
| 1 s
| 1 s
| (*)
| (*)
|-
|-
| [[Turbo Pascal]]
| [[Turbo Pascal]]
| <tt>GetTime()</tt><br /> <tt>GetDate()</tt>
| {{code|GetTime()}}<br /> {{code|GetDate()}}
| 10 ms
| 10 ms
| (*)
| (*)
|-
|-
| rowspan="2" | [[Perl]]
| rowspan="2" | [[Perl]]
| <tt>time()</tt>
| {{code|time()}}
| 1 s
| 1 s
| rowspan="2" | 1 January 1970
| rowspan="2" | 1 January 1970
|-
|-
| <tt>Time::HiRes::time</tt><ref>Douglas Wegscheild, R. Schertler, and Jarkko Hietaniemi, [https://metacpan.org/module/Time::HiRes "Time::HiRes"] (CPAN
| {{code|Time::HiRes::time}}<ref>Douglas Wegscheild, R. Schertler, and Jarkko Hietaniemi, {{cite web|url=https://metacpan.org/module/Time::HiRes|title=Time::HiRes|work=CPAN - Comprehensive Perl Archive Network|date=2011|access-date=27 October 2011}}</ref>
Comprehensive Perl Archive Network, 2011) accessed 27 October 2011.</ref>
| 1 μs
| 1 μs
|-
|-
| rowspan="2" | [[PHP]]
| rowspan="2" | [[PHP]]
| <tt>time()</tt><br /><tt>mktime()</tt>
| {{code|time()}}<br />{{code|mktime()}}
| 1 s
| 1 s
| rowspan="2" | 1 January 1970
| rowspan="2" | 1 January 1970
|-
|-
| <tt>microtime()</tt>
| {{code|microtime()}}
| 1 μs
| 1 μs
|-
| [[PureBasic]]
| {{code|Date()}}
| 1 s
| 1 January 1970 to 19 January 2038
|-
|-
| [[Python (programming language)|Python]]
| [[Python (programming language)|Python]]
| <tt>datetime.now().timestamp()</tt>
| {{code|datetime.now().timestamp()}}
| 1 μs (*)
| 1 μs (*)
| 1 January 1970
| 1 January 1970
|-
|-
| rowspan="2" | [[IBM RPG|RPG]]
| rowspan="2" | [[IBM RPG|RPG]]
| <tt>CURRENT(DATE)</tt>, <tt>%DATE</tt><br/> <tt>CURRENT(TIME)</tt>, <tt>%TIME</tt>
| {{code|CURRENT(DATE)}}, {{code|%DATE}}<br/> {{code|CURRENT(TIME)}}, {{code|%TIME}}
| 1 s
| 1 s
| rowspan="2" | 1 January 0001 to 31 December 9999
| rowspan="2" | 1 January 0001 to 31 December 9999
|-
|-
| <tt>CURRENT(TIMESTAMP)</tt>, <tt>%TIMESTAMP</tt>
| {{code|CURRENT(TIMESTAMP)}}, {{code|%TIMESTAMP}}
| 1 μs
| 1 μs
|-
|-
| [[Ruby (programming language)|Ruby]]
| [[Ruby (programming language)|Ruby]]
| <tt>Time.now()</tt><ref>[http://www.ruby-doc.org/core/classes/Time.html Time class] in ''Ruby-Doc.org: Help and documentation for the Ruby programming language'' (Scottsdale, AZ: James Britt and Neurogami) accessed 27 October 2011.</ref>
| {{code|Time.now()}}<ref>{{cite web|url=https://ruby-doc.org/core/Time.html|title=Time class|website=Ruby-Doc.org: Help and documentation for the Ruby programming language|location=Scottsdale, AZ|author1=James Britt|author2=Neurogami|access-date=27 October 2011}}</ref>
| 1 μs (*)
| 1 μs (*)
| 1 January 1970 (to 19 January 2038 prior to Ruby 1.9.2<ref>[http://www.ruby-lang.org/en/news/2010/08/18/ruby-1-9.2-released/ Ruby 1.9.2 Release Notes] in ''Ruby-Doc.org: Help and documentation for the Ruby programming language'' (Scottsdale, AZ: James Britt and Neurogami) accessed 27 October 2011.</ref>)
| 1 January 1970<br/>(to 19 January 2038 prior to Ruby 1.9.2<ref>{{cite web|url=https://www.ruby-lang.org/en/news/2010/08/18/ruby-1-9-2-released/|title=Ruby 1.9.2 is released|author=Yugui|date=18 August 2010|quote=The new 1.9.2 is almost compatible with 1.9.1, except these changes: ... Time is reimplemented. The bug with year 2038 is fixed.}}</ref>)
|-
| [[Scheme (programming language)|Scheme]]
| {{code|(get-universal-time)}}<ref>{{cite web| url=https://edoras.sdsu.edu/doc/mit-scheme-9.2/mit-scheme-ref/Date-and-Time.html |title=MIT/GNU Scheme 9.2: 15.5 Date and Time |date=}}</ref>
| 1 s
| 1 January 1900
|-
|-
| rowspan="3" | [[Smalltalk]]
| rowspan="3" | [[Smalltalk]]
| <tt>Time microsecondClock</tt><br/> {{small|(VisualWorks)}}
| {{code|Time microsecondClock}}<br/> {{small|(VisualWorks)}}
| rowspan="3" | 1 s {{small|(ANSI)}}<br/> 1 μs {{small|(VisualWorks)}}<br/> 1 s {{small|(Squeak)}}
| rowspan="3" | 1 s {{small|(ANSI)}}<br/> 1 μs {{small|(VisualWorks)}}<br/> 1 s {{small|(Squeak)}}
| rowspan="3" | 1 January 1901 (*)
| rowspan="3" | 1 January 1901 (*)
|-
|-
| <tt>Time totalSeconds</tt><br/> {{small|(Squeak)}}
| {{code|Time totalSeconds}}<br/> {{small|(Squeak)}}
|-
|-
| <tt>SystemClock ticksNowSinceSystemClockEpoch</tt><br/> {{small|(Chronos)}}
| {{code|SystemClock ticksNowSinceSystemClockEpoch}}<br/> {{small|(Chronos)}}
|-
|-
| rowspan="2" | [[SQL]]
| rowspan="2" | [[SQL]]
| rowspan="2" | <tt>CURDATE()</tt><br/> <tt>CURTIME()</tt><br/> <tt>GETDATE()</tt><br/> <tt>NOW()</tt><br/> <tt>SYSDATE()</tt>
| rowspan="2" | {{code|CURDATE()}} or {{code|CURRENT DATE}}<br/> {{code|CURTIME()}} or {{code|CURRENT TIME}}<br/> {{code|GETDATE()}} or {{code|GETUTCDATE()}}<br/> {{code|NOW()}} or {{code|CURRENT TIMESTAMP}}<br/> {{code|SYSDATE()}}
| 3 ms
| 3 ms
| 1 January 1753 to 31 December 9999 (*) <!-- MySQL; Oracle has BC 4712 to AD 9999 -->
| 1 January 1753 to 31 December 9999 (*) <!-- MySQL; Oracle has BC 4712 to AD 9999 -->
Line 359: Line 388:
|-
|-
| [[Standard ML]]
| [[Standard ML]]
| <tt>Time.now()</tt>
| {{code|Time.now()}}
| 1 μs (*)
| 1 μs (*)
| 1 January 1970 (*)
| 1 January 1970 (*)
|-
|-
| rowspan="4" | [[Tcl|TCL]]
| rowspan="4" | [[Tcl|TCL]]
| <tt>[clock seconds]</tt>
| {{code|[clock seconds]}}
| 1 s
| 1 s
| rowspan="3" | 1 January 1970
| rowspan="3" | 1 January 1970
|-
|-
| <tt>[clock milliseconds]</tt>
| {{code|[clock milliseconds]}}
| 1 ms
| 1 ms
|-
|-
| <tt>[clock microseconds]</tt>
| {{code|[clock microseconds]}}
| 1 μs
| 1 μs
|-
|-
| <tt>[clock clicks]</tt>
| {{code|[clock clicks]}}
| 1 μs (*)
| 1 μs (*)
| (*)
| (*)
|-
|-
| rowspan="2" | [[Windows PowerShell]]
| rowspan="2" | [[Windows PowerShell]]
| <tt>Get-Date</tt><ref name="ms-technet10">{{cite web |url=https://technet.microsoft.com/en-us/library/ee176845.aspx |title=Using the Get-Date Cmdlet |publisher=Microsoft TechNet |accessdate=11 December 2013}}</ref><ref name="ms-technet11">{{cite web |url=https://technet.microsoft.com/en-us/library/ee692801.aspx |title=Windows PowerShell Tip of the Week – Formatting Dates and Times |publisher=Microsoft TechNet |accessdate=11 December 2013}}</ref>
| {{code|Get-Date}}<ref name="ms-technet10">{{cite web |url=https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-powershell-1.0/ee176845(v=technet.10) |title=Using the Get-Date Cmdlet |website=Microsoft Docs |date=22 October 2009 |access-date=23 July 2019}}</ref><ref name="ms-technet11">{{cite web |url=https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-powershell-1.0/ee692801(v=technet.10) |title=Windows PowerShell Tip of the Week – Formatting Dates and Times |website=Microsoft Docs |date=26 May 2010 |access-date=23 July 2019}}</ref>
| rowspan="2" | 100 ns<ref name="dotnet"/>
| rowspan="2" | 100 ns<ref name="dotnet"/>
| rowspan="2" | 1 January 0001 to 31 December 9999
| rowspan="2" | 1 January 0001 to 31 December 9999
|-
|-
| <tt>[DateTime]::Now</tt><ref name="ms-datetime"/><br/> <tt>[DateTime]::UtcNow</tt><ref name="ms-utcnow"/>
| {{code|[DateTime]::Now}}<ref name="ms-datetime"/><br/> {{code|[DateTime]::UtcNow}}<ref name="ms-utcnow"/>
|-
|-
| [[Visual Basic .NET]] ([[Microsoft]])
| [[Visual Basic .NET]]
| <tt>System.DateTime.Now</tt><ref name="ms-datetime"/><br/> <tt>System.DateTime.UtcNow</tt><ref name="ms-utcnow"/>
| {{code|System.DateTime.Now}}<ref name="ms-datetime"/><br/> {{code|System.DateTime.UtcNow}}<ref name="ms-utcnow"/>
| 100 ns<ref name="dotnet"/>
| 100 ns<ref name="dotnet"/>
| 1 January 0001 to 31 December 9999
| 1 January 0001 to 31 December 9999
Line 392: Line 421:


==See also==
==See also==
{{columns-list|colwidth=18em|
{{Portal|Time}} <!-- located here in order to render correctly without extra vertical whitespace (IE6) -->
{{columns-list|4|
* [[Calendar]]
* [[Calendar]]
* [[Computation time]]
* [[DATE (command)]]
* [[DATE (command)]]
* [[Epoch (reference date)|Epoch]]
* [[Epoch (computing)|Epoch]]
* [[Global Positioning System|GPS time]]
* [[Global Positioning System|GPS time]]
* [[Jiffy (time)|Jiffy]]
* [[Jiffy (time)|Jiffy]]
* [[Network Time Protocol]]
* [[Network Time Protocol]]
* [[Process (computing)|Process]]
* [[rdate]]
* [[rdate]]
* [[TIME (command)]]
* [[TIME (command)]]
Line 407: Line 433:
* [[time_t]] <!--yes, the underscore is an essential part of the page's name; the name is a C typedef from UNIX, so spaces aren't allowed in the name-->
* [[time_t]] <!--yes, the underscore is an essential part of the page's name; the name is a C typedef from UNIX, so spaces aren't allowed in the name-->
* [[Time formatting and storage bugs]]
* [[Time formatting and storage bugs]]
* [[TIME protocol]]
* [[Time Protocol]]
* [[Time-sharing]]
* [[Time standard]]
* [[Time standard]]
* [[Timer]]
* [[Timestamp]]
* [[Timestamp]]
* [[date (Unix)|Unix date command]]
* [[date (Unix)|Unix date command]]
* [[Unix time]]
* [[Unix time]]
* [[time (Unix)|Unix time command]]
* [[time (Unix)|Unix time command]]
* [[Wall clock time]]
* [[Elapsed real time]]
* [[Year 2000 problem]]
* [[Year 2000 problem]]
* [[Year 2038 problem]]
* [[Year 2038 problem]]
Line 429: Line 453:
==External links==
==External links==
* ''[http://people.cs.nctu.edu.tw/~tsaiwn/sisc/runtime_error_200_div_by_0/www.merlyn.demon.co.uk/critdate.htm Critical and Significant Dates]'', J. R. Stockton ''(retrieved 3 December 2015)'' <!-- Extensive list of dates that are problematic for various operating systems and computing devices -->
* ''[http://people.cs.nctu.edu.tw/~tsaiwn/sisc/runtime_error_200_div_by_0/www.merlyn.demon.co.uk/critdate.htm Critical and Significant Dates]'', J. R. Stockton ''(retrieved 3 December 2015)'' <!-- Extensive list of dates that are problematic for various operating systems and computing devices -->
* ''[http://www.boost.org/doc/html/date_time.html The Boost Date/Time Library]'' (C++)''
* ''[http://www.boost.org/doc/html/date_time.html The Boost Date/Time Library]'' (C++)
* ''[http://www.boost.org/doc/html/chrono.html The Boost Chrono Library]'' (C++)''
* ''[http://www.boost.org/doc/html/chrono.html The Boost Chrono Library]'' (C++)
* ''[http://www.chronos-st.org/ The Chronos Date/Time Library]'' (Smalltalk)''
* ''[http://www.chronos-st.org/ The Chronos Date/Time Library]'' (Smalltalk)
* ''[http://www.joda.org/joda-time/ Joda Time]'', The Joda Date/Time Library (Java)''
* ''[http://www.joda.org/joda-time/ Joda Time]'', The Joda Date/Time Library (Java)
* ''[http://datetime.perl.org/ The Perl DateTime Project ]'' (Perl)''
* ''[http://datetime.perl.org/ The Perl DateTime Project ] {{Webarchive|url=https://web.archive.org/web/20090219220835/http://datetime.perl.org/ |date=2009-02-19 }}'' (Perl)
* ''[http://www.ruby-doc.org/stdlib/libdoc/date/rdoc/files/date_rb.html The Ruby Date/Time Library ]'' (Ruby)''
* ''[http://ruby-doc.org/stdlib-2.5.1/libdoc/date/rdoc/index.html date: Ruby Standard Library Documentation]'' (Ruby)


{{Time Topics}}
{{Time Topics}}

Latest revision as of 18:37, 30 September 2024

Unix date command

In computer science and computer programming, system time represents a computer system's notion of the passage of time. In this sense, time also includes the passing of days on the calendar.

System time is measured by a system clock, which is typically implemented as a simple count of the number of ticks that have transpired since some arbitrary starting date, called the epoch. For example, Unix and POSIX-compliant systems encode system time ("Unix time") as the number of seconds elapsed since the start of the Unix epoch at 1 January 1970 00:00:00 UT, with exceptions for leap seconds. Systems that implement the 32-bit and 64-bit versions of the Windows API, such as Windows 9x and Windows NT, provide the system time as both SYSTEMTIME, represented as a year/month/day/hour/minute/second/milliseconds value, and FILETIME, represented as a count of the number of 100-nanosecond ticks since 1 January 1601 00:00:00 UT as reckoned in the proleptic Gregorian calendar.

System time can be converted into calendar time, which is a form more suitable for human comprehension. For example, the Unix system time 1000000000 seconds since the beginning of the epoch translates into the calendar time 9 September 2001 01:46:40 UT. Library subroutines that handle such conversions may also deal with adjustments for time zones, daylight saving time (DST), leap seconds, and the user's locale settings. Library routines are also generally provided that convert calendar times into system times.

Many implementations that currently store system times as 32-bit integer values will suffer from the impending Year 2038 problem. These time values will overflow ("run out of bits") after the end of their system time epoch, leading to software and hardware errors. These systems will require some form of remediation, similar to efforts required to solve the earlier Year 2000 problem. This will also be a potentially much larger problem for existing data file formats that contain system timestamps stored as 32-bit values.

Other time measurements

[edit]

Closely related to system time is process time, which is a count of the total CPU time consumed by an executing process. It may be split into user and system CPU time, representing the time spent executing user code and system kernel code, respectively. Process times are a tally of CPU instructions or clock cycles and generally have no direct correlation to wall time.

File systems keep track of the times that files are created, modified, and/or accessed by storing timestamps in the file control block (or inode) of each file and directory.

History

[edit]

Most first-generation personal computers did not keep track of dates and times. These included systems that ran the CP/M operating system, as well as early models of the Apple II, the BBC Micro, and the Commodore PET, among others. Add-on peripheral boards that included real-time clock chips with on-board battery back-up were available for the IBM PC and XT, but the IBM AT was the first widely available PC that came equipped with date/time hardware built into the motherboard. Prior to the widespread availability of computer networks, most personal computer systems that did track system time did so only with respect to local time and did not make allowances for different time zones.

With current technology, most modern computers keep track of local civil time, as do many other household and personal devices such as VCRs, DVRs, cable TV receivers, PDAs, pagers, cell phones, fax machines, telephone answering machines, cameras, camcorders, central air conditioners, and microwave ovens.

Microcontrollers operating within embedded systems (such as the Raspberry Pi, Arduino, and other similar systems) do not always have internal hardware to keep track of time. Many such controller systems operate without knowledge of the external time. Those that require such information typically initialize their base time upon rebooting by obtaining the current time from an external source, such as from a time server or external clock, or by prompting the user to manually enter the current time.

Implementation

[edit]

The system clock is typically implemented as a programmable interval timer that periodically interrupts the CPU, which then starts executing a timer interrupt service routine. This routine typically adds one tick to the system clock (a simple counter) and handles other periodic housekeeping tasks (preemption, etc.) before returning to the task the CPU was executing before the interruption.

Retrieving system time

[edit]
03 January 2025 14:12:48 UTC

The Wikipedia system time when this page was last generated.
Purge this page, and update this counter.

The following tables illustrate methods for retrieving the system time in various operating systems, programming languages, and applications. Values marked by (*) are system-dependent and may differ across implementations. All dates are given as Gregorian or proleptic Gregorian calendar dates.

The resolution of an implementation's measurement of time does not imply the same precision of such measurements. For example, a system might return the current time as a value measured in microseconds, but actually be capable of discerning individual clock ticks with a frequency of only 100 Hz (10 ms).

Operating systems

[edit]
Operating system Command or function Resolution Epoch or range
Android java.lang.System.currentTimeMillis() 1 ms 1 January 1970
BIOS (IBM PC) INT 1Ah, AH=00h[1] 54.9254 ms
18.2065 Hz
Midnight of the current day
INT 1Ah, AH=02h[2] 1 s Midnight of the current day
INT 1Ah, AH=04h[3] 1 day 1 January 1980 to 31 December 1999 or 31 December 2079 (system dependent)
CP/M Plus System Control Block:[4]
scb$base+58h, Days since 31 December 1977
scb$base+5Ah, Hour (BCD)
scb$base+5Bh, Minute (BCD)
scb$base+5Ch, Second (BCD)
1 s 31 December 1977 to 5 June 2157
BDOS function 69h> (T_GET):[5]
word, Days since 1 January 1978
byte, Hour (BCD)
byte, Minute (BCD)
byte, Second (BCD)
DOS (Microsoft) C:\> DATE
C:\> TIME
10 ms 1 January 1980 to 31 December 2099
INT 21h, AH=2Ch SYSTEM TIME[6]
INT 21h, AH=2Ah SYSTEM DATE[7]
iOS (Apple) CFAbsoluteTimeGetCurrent()[8] < 1 ms 1 January 2001 ±10,000 years
macOS CFAbsoluteTimeGetCurrent()[9] < 1 ms[10][note 1] 1 January 2001 ±10,000 years[10][note 1]
OpenVMS SYS$GETTIM() 100 ns[11] 17 November 1858 to 31 July 31,086[12]
gettimeofday() 1 μs[13] 1 January 1970 to 7 February 2106[14]
clock_gettime() 1 ns[13]
z/OS STCK[15]: 7–187  2−12 μs
244.14 ps[15]: 4–45, 4–46 
1 January 1900 to 17 September 2042 UT[16]
STCKE 1 January 1900 to AD 36,765[17]
Unix, POSIX
(see also C date and time functions)
$date
time()
1 s (*)
1 January 1970 (to 19 January 2038 prior to Linux 5.9) to 2 July 2486 (Since Linux 5.10)
1 January 1970 to 4 December AD 292,277,026,596
gettimeofday() 1 μs
clock_gettime() 1 ns
OS/2 DosGetDateTime() 10 ms 1 January 1980 to 31 December 2079[18]
Windows GetSystemTime() 1 ms 1 January 1601 to 14 September 30828, 02:48:05.4775807
GetSystemTimeAsFileTime() 100 ns
GetSystemTimePreciseAsFileTime()

Programming languages and applications

[edit]
Language/Application Function or variable Resolution Epoch or range
Ada Ada.Calendar.Clock 100 μs to
20 ms (*)
1 January 1901 to 31 December 2099 (*)
AWK systime() 1 s (*)
BASIC, True BASIC DATE, DATE$
TIME, TIME$
1 s (*)
Business BASIC DAY, TIM 0.1 s (*)
C (see C date and time functions) time() 1 s (*)[note 2] (*)[note 2]
C++ std::time()
std::chrono::system_clock::now()
1 s (*)[note 2]
1 ns (C++11, OS dependent)
(*)[note 2]
C# System.DateTime.Now[19]
System.DateTime.UtcNow[20]
100 ns[21] 1 January 0001 to 31 December 9999
CICS ASKTIME 1 ms 1 January 1900
COBOL FUNCTION CURRENT-DATE 1 s 1 January 1601
Common Lisp (get-universal-time) 1 s 1 January 1900
Delphi (Borland) date
time
1 ms
(floating point)
1 January 1900
Delphi
(Embarcadero Technologies)[22]
System.SysUtils.Time[23] 1 ms 0/0/0000 0:0:0:000 to
12/31/9999 23:59:59:999 [sic]
System.SysUtils.GetTime[24] (alias for System.SysUtils.Time)
System.SysUtils.Date[25] 0/0/0000 0:0:0:000 to
12/31/9999 0:0:0:000 [sic]
System.DateUtils.Today[26]
System.DateUtils.Tomorrow[27]
System.DateUtils.Yesterday[28]
System.SysUtils.Now[29] 1 s 0/0/0000 0:0:0:000 to
12/31/9999 23:59:59:000 [sic]
System.SysUtils.DayOfWeek[30] 1 day 1 to 7
System.SysUtils.CurrentYear[31] 1 year (*)
Emacs Lisp (current-time) 1 μs (*) 1 January 1970
Erlang erlang:system_time(), os:system_time()[32] OS dependent, e.g. on Linux 1ns[32] 1 January 1970[32]
Excel date() ? 0 January 1900[33]
Fortran DATE_AND_TIME
SYSTEM_CLOCK
(*)[34]

[35]

1 January 1970
CPU_TIME 1 μs
Go time.Now() 1 ns 1 January 0001
Haskell Time.getClockTime 1 ps (*) 1 January 1970 (*)
Data.Time.getCurrentTime 1 ps (*) 17 November 1858 (*)
Java java.util.Date()
System.currentTimeMillis()
1 ms 1 January 1970
System.nanoTime()[36] 1 ns arbitrary[36]
Clock.systemUTC()[37] 1 ns arbitrary[38]
JavaScript, TypeScript (new Date()).getTime()
Date.now()
1 ms 1 January 1970
Matlab now 1 s 0 January 0000[39]
MUMPS $H (short for $HOROLOG) 1 s 31 December 1840
LabVIEW Tick Count 1 ms 00:00:00.000 1 January 1904
Get Date/Time in Seconds 1 ms 00:00:00.000 1 January 1904
Objective-C [NSDate timeIntervalSinceReferenceDate] < 1 ms[40] 1 January 2001 ±10,000 Years[40]
OCaml Unix.time() 1 s 1 January 1970
Unix.gettimeofday() 1 μs
Extended Pascal GetTimeStamp() 1 s (*)
Turbo Pascal GetTime()
GetDate()
10 ms (*)
Perl time() 1 s 1 January 1970
Time::HiRes::time[41] 1 μs
PHP time()
mktime()
1 s 1 January 1970
microtime() 1 μs
PureBasic Date() 1 s 1 January 1970 to 19 January 2038
Python datetime.now().timestamp() 1 μs (*) 1 January 1970
RPG CURRENT(DATE), %DATE
CURRENT(TIME), %TIME
1 s 1 January 0001 to 31 December 9999
CURRENT(TIMESTAMP), %TIMESTAMP 1 μs
Ruby Time.now()[42] 1 μs (*) 1 January 1970
(to 19 January 2038 prior to Ruby 1.9.2[43])
Scheme (get-universal-time)[44] 1 s 1 January 1900
Smalltalk Time microsecondClock
(VisualWorks)
1 s (ANSI)
1 μs (VisualWorks)
1 s (Squeak)
1 January 1901 (*)
Time totalSeconds
(Squeak)
SystemClock ticksNowSinceSystemClockEpoch
(Chronos)
SQL CURDATE() or CURRENT DATE
CURTIME() or CURRENT TIME
GETDATE() or GETUTCDATE()
NOW() or CURRENT TIMESTAMP
SYSDATE()
3 ms 1 January 1753 to 31 December 9999 (*)
60 s 1 January 1900 to 6 June 2079
Standard ML Time.now() 1 μs (*) 1 January 1970 (*)
TCL [clock seconds] 1 s 1 January 1970
[clock milliseconds] 1 ms
[clock microseconds] 1 μs
[clock clicks] 1 μs (*) (*)
Windows PowerShell Get-Date[45][46] 100 ns[21] 1 January 0001 to 31 December 9999
[DateTime]::Now[19]
[DateTime]::UtcNow[20]
Visual Basic .NET System.DateTime.Now[19]
System.DateTime.UtcNow[20]
100 ns[21] 1 January 0001 to 31 December 9999

See also

[edit]

Notes

[edit]
  1. ^ a b The Apple Developer Documentation is not clear on the precision & range of CFAbsoluteTime/CFTimeInterval, except in the CFRunLoopTimerCreate documentation which refers to 'sub-millisecond at most' precision. However, the similar type NSTimeInterval appears to be interchangeable, and has the precision and range listed.
  2. ^ a b c d The C standard library does not specify any specific resolution, epoch, range, or datatype for system time values. The C++ library encompasses the C library, so it uses the same system time implementation as C.

References

[edit]
  1. ^ Ralf D. Brown (2000). "Int 0x1A, AH=0x00". Ralf Brown's Interrupt List.
  2. ^ Ralf D. Brown (2000). "Int 0x1A, AH=0x02". Ralf Brown's Interrupt List.
  3. ^ Ralf D. Brown (2000). "Int 0x1A, AH=0x04". Ralf Brown's Interrupt List.
  4. ^ "CP/M Plus (CP/M Version 3.0) Operating System Guide" (PDF).
  5. ^ "BDOS system calls".
  6. ^ Ralf D. Brown (2000). "Int 0x21, AH=0x2c". Ralf Brown's Interrupt List.
  7. ^ Ralf D. Brown (2000). "Int 0x21, AH=0x2a". Ralf Brown's Interrupt List.
  8. ^ "Time Utilities Reference". iOS Developer Library. 2007.
  9. ^ "Time Utilities Reference". Mac OS X Developer Library. 2007.
  10. ^ a b "Time Utilities - Foundation". Apple Developer Documentation. Retrieved 6 July 2022.
  11. ^ Ruth E. Goldenberg; Lawrence J. Kenah; Denise E. Dumas (1991). VAX/VMS Internals and Data Structures, Version 5.2. Digital Press. ISBN 978-1555580599.
  12. ^ "Why is Wednesday, November 17, 1858 the base time for OpenVMS (VAX VMS)?". Stanford University. 24 July 1997. Archived from the original on 24 July 1997. Retrieved 8 January 2020.
  13. ^ a b "VSI C Run-Time Library Reference Manual for OpenVMS Systems" (PDF). VSI. November 2020. Retrieved 2021-04-17.
  14. ^ "OpenVMS and the year 2038". HP. Retrieved 2021-04-17.
  15. ^ a b z/Architecture Principles of Operation (PDF). Poughkeepsie, New York: International Business Machines. 2007.
  16. ^ IBM intends to extend the date range on future systems beyond 2042. z/Architecture Principles of Operation, (Poughkeepsie, New York:International Business Machines, 2007) 1-15, 4-45 to 4-47.
  17. ^ "Expanded 64-bit time values". IBM. Retrieved 2021-04-18.
  18. ^ Jonathan de Boyne Pollard. "The 32-bit Command Interpreter". On OS/2 Warp 4, date and time can both operate well beyond the year 2000, and even well beyond the year 2038, and in fact up to the year 2079, which is the limit for OS/2 Warp 4's real-time clock.
  19. ^ a b c "DateTime.Now Property". Microsoft Docs.
  20. ^ a b c "DateTime.UtcNow Property". Microsoft Docs.
  21. ^ a b c "DateTime.Ticks Property". Microsoft Docs.
  22. ^ "Date and Time Support". Embarcadero Developer Network. 2013.
  23. ^ "System.SysUtils.Time". Embarcadero Developer Network. 2013.
  24. ^ "System.SysUtils.GetTime". Embarcadero Developer Network. 2013.
  25. ^ "System.SysUtils.Date". Embarcadero Developer Network'. 2013.
  26. ^ "System.DateUtils.Today". Embarcadero Developer Network. 2013.
  27. ^ "System.DateUtils.Tomorrow". Embarcadero Developer Network. 2013.
  28. ^ "System.DateUtils.Yesterday". Embarcadero Developer Network. 2013.
  29. ^ "System.SysUtils.Now". Embarcadero Developer Network. 2013.
  30. ^ "System.SysUtils.DayOfWeek". Embarcadero Developer Network. 2013.
  31. ^ "System.SysUtils.CurrentYear". Embarcadero Developer Network. 2013.
  32. ^ a b c "Time and Time Correction in Erlang". www.erlang.org.
  33. ^ "XL2000: Early Dates on Office Spreadsheet Component Differ from Excel". Microsoft Support. 2003. Archived from the original on 24 October 2007. In the Microsoft Office Spreadsheet Component, the value 0 evaluates to the date December 30, 1899 and the value 1 evaluates to December 31, 1899. ... In Excel, the value 0 evaluates to January 0, 1900 and the value 1 evaluates to January 1, 1900.
  34. ^ "SYSTEM_CLOCK". Intel Fortran Compiler 19.0 Developer Guide and Reference. 29 April 2019. Retrieved 23 July 2019.
  35. ^ "SYSTEM_CLOCK — Time function". The GNU Fortran Compiler. Retrieved 27 October 2011.
  36. ^ a b "System.nanoTime() method". Java Platform, Standard Edition 6: API Specification. 2015. Retrieved 23 July 2019.
  37. ^ "Clock.systemUTC() and other methods". Java Platform, Standard Edition 8: API Specification. 2014. Retrieved 15 January 2015.
  38. ^ "JSR-310 Java Time System". Java Platform, Standard Edition 8: API Specification. 2014. Retrieved 15 January 2015.
  39. ^ "Matlab Help".
  40. ^ a b "NSTimeInterval - Foundation". Apple Developer Documentation.
  41. ^ Douglas Wegscheild, R. Schertler, and Jarkko Hietaniemi, "Time::HiRes". CPAN - Comprehensive Perl Archive Network. 2011. Retrieved 27 October 2011.
  42. ^ James Britt; Neurogami. "Time class". Ruby-Doc.org: Help and documentation for the Ruby programming language. Scottsdale, AZ. Retrieved 27 October 2011.
  43. ^ Yugui (18 August 2010). "Ruby 1.9.2 is released". The new 1.9.2 is almost compatible with 1.9.1, except these changes: ... Time is reimplemented. The bug with year 2038 is fixed.
  44. ^ "MIT/GNU Scheme 9.2: 15.5 Date and Time".
  45. ^ "Using the Get-Date Cmdlet". Microsoft Docs. 22 October 2009. Retrieved 23 July 2019.
  46. ^ "Windows PowerShell Tip of the Week – Formatting Dates and Times". Microsoft Docs. 26 May 2010. Retrieved 23 July 2019.
[edit]