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.
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. 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.
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.
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
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.
Note that 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 system||Command or function||Resolution||Epoch or range|
||1 ms||1 January 1970|
|BIOS (IBM PC)||INT 1Ah, AH=00h||54.9254 ms
|Midnight of the current day|
|INT 1Ah, AH=02h||1 s||Midnight of the current day|
|INT 1Ah, AH=04h||1 day||1 January 1980 to 31 December 1999 or 31 December 2079 (system dependent)|
|CP/M Plus||System Control Block:
scb$base+58h, Days since 1 Jan 1978
scb$base+5Ah, Hour (BCD)
scb$base+5Bh, Minute (BCD)
scb$base+5Ch, Second (BCD)
|1 s||1 January 1978 to September 2067|
|BDOS function 69h (T_GET):|
word, Days since 1 January 1978
byte, Hour (BCD)
byte, Minute (BCD)
byte, Second (BCD)
|10 ms||1 January 1980 to 31 December 2099|
|INT 21h, AH=2Ch SYSTEM TIME|
INT 21h, AH=2Ah SYSTEM DATE
|iOS (Apple)||CFAbsoluteTimeGetCurrent()||< 1 ms||1 January 2001 ±10,000 years|
|macOS||CFAbsoluteTimeGetCurrent()||< 1 ms[note 1]||1 January 2001 ±10,000 years[note 1]|
|OpenVMS||SYS$GETTIM()||100 ns||17 November 1858 to AD 31,086|
244.14 ps:4-45, 4-46
|1 January 1900 to 17 September 2042 UT|
(see also C date and time functions)
1 January 1970 to 19 January 2038
1 January 1970 to AD 292,277,026,596
|OS/2||DosGetDateTime()||10 ms||1 January 1980 to 31 December 2079|
|Windows||GetSystemTime()||1 ms||1 January 1601 to 14 September 30,828|
Programming languages and applications
|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 (*)|
|BASIC, True BASIC||DATE, DATE$
|Business BASIC||DAY, TIM||0.1 s||(*)|
|C (see C date and time functions)||time()||1 s (*)[note 2]||(*)[note 2]|
|1 s (*)[note 2]
1 ns (C++11, OS dependent)
|100 ns||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|
|1 January 1900|
|System.SysUtils.Time||1 ms||0/0/0000 0:0:0:000 to 12/31/9999 23:59:59:999 [sic]|
|System.SysUtils.GetTime (alias for System.SysUtils.Time)|
|System.SysUtils.Date||0/0/0000 0:0:0:000 to 12/31/9999 0:0:0:000 [sic]|
|System.SysUtils.Now||1 s||0/0/0000 0:0:0:000 to 12/31/9999 23:59:59:000 [sic]|
|System.SysUtils.DayOfWeek||1 day||1 to 7|
|Emacs Lisp||(current-time)||1 μs (*)||1 January 1970|
|Erlang||erlang:system_time(), os:system_time()||OS dependent, e.g. on Linux 1ns||1 January 1970|
|Excel||date()||?||0 January 1900|
|(*)||1 January 1970|
|Go||time.Now()||1 ns||1 January 0001|
|Haskell||Time.getClockTime||1 ps (*)||1 January 1970 (*)|
|Data.Time.getCurrentTime||1 ps (*)||17 November 1858 (*)|
|1 ms||1 January 1970|
|1 ms||1 January 1970|
|Matlab||now||1 s||0 January 0000|
|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||1 January 2001 ±10,000 Years|
|OCaml||Unix.time()||1 s||1 January 1970|
|Extended Pascal||GetTimeStamp()||1 s||(*)|
|Perl||time()||1 s||1 January 1970|
|1 s||1 January 1970|
|Python||datetime.now().timestamp()||1 μs (*)||1 January 1970|
|1 s||1 January 0001 to 31 December 9999|
|CURRENT(TIMESTAMP), %TIMESTAMP||1 μs|
|Ruby||Time.now()||1 μs (*)||1 January 1970 (to 19 January 2038 prior to Ruby 1.9.2)|
|1 s (ANSI)
1 μs (VisualWorks)
1 s (Squeak)
|1 January 1901 (*)|
|SQL||CURDATE() or CURRENT DATE
CURTIME() or CURRENT TIME
NOW() or CURRENT TIMESTAMP
|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||100 ns||1 January 0001 to 31 December 9999|
|Visual Basic .NET||System.DateTime.Now
|100 ns||1 January 0001 to 31 December 9999|
- Computation time
- DATE (command)
- GPS time
- Network Time Protocol
- TIME (command)
- Time formatting and storage bugs
- TIME protocol
- Time standard
- Unix date command
- Unix time
- Unix time command
- Wall-clock time
- Year 2000 problem
- Year 2038 problem
- 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.
- 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.
- Ralf D. Brown (2000). "Int 0x1A, AH=0x00". Ralf Brown's Interrupt List.
- Ralf D. Brown (2000). "Int 0x1A, AH=0x02". Ralf Brown's Interrupt List.
- Ralf D. Brown (2000). "Int 0x1A, AH=0x04". Ralf Brown's Interrupt List.
- "CP/M Plus (CP/M Version 3.0) Operating System Guide" (PDF).
- "BDOS system calls".
- Ralf D. Brown (2000). "Int 0x21, AH=0x2c". Ralf Brown's Interrupt List.
- Ralf D. Brown (2000). "Int 0x21, AH=0x2a". Ralf Brown's Interrupt List.
- "Time Utilities Reference". iOS Developer Library. 2007.
- "Time Utilities Reference". Mac OS X Developer Library. 2007.
- "CFRunLoopTimerCreate - Core Foundation". Apple Developer Documentation. 2007.
- z/Architecture Principles of Operation (PDF). Poughkeepsie, New York: International Business Machines. 2007.
- 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.
- 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.
- Anders Thulin (6 April 2013). "Interpretation of NTFS Timestamps". Forensic Focus.
- "DateTime.Now Property". Microsoft Docs.
- "DateTime.UtcNow Property". Microsoft Docs.
- "DateTime.Ticks Property". Microsoft Docs.
- "Date and Time Support". Embarcadero Developer Network. 2013.
- "System.SysUtils.Time". Embarcadero Developer Network. 2013.
- "System.SysUtils.GetTime". Embarcadero Developer Network. 2013.
- "System.SysUtils.Date". Embarcadero Developer Network'. 2013.
- "System.DateUtils.Today"". Embarcadero Developer Network. 2013.
- "System.DateUtils.Tomorrow". Embarcadero Developer Network. 2013.
- "System.DateUtils.Yesterday". Embarcadero Developer Network. 2013.
- "System.SysUtils.Now". Embarcadero Developer Network. 2013.
- "System.SysUtils.DayOfWeek". Embarcadero Developer Network. 2013.
- "System.SysUtils.CurrentYear". Embarcadero Developer Network. 2013.
- Time and Time Correction in Erlang
- "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.
- "SYSTEM_CLOCK". Intel Fortran Compiler 19.0 Developer Guide and Reference. 29 April 2019. Retrieved 23 July 2019.
- "SYSTEM_CLOCK — Time function". The GNU Fortran Compiler. Retrieved 27 October 2011.
- "System.nanoTime() method". Java Platform, Standard Edition 6: API Specification. 2015. Retrieved 23 July 2019.
- "Clock.systemUTC() and other methods". Java Platform, Standard Edition 8: API Specification. 2014. Retrieved 15 January 2015.
- "JSR-310 Java Time System". Java Platform, Standard Edition 8: API Specification. 2014. Retrieved 15 January 2015.
- "Matlab Help".
- "NSTimeInterval - Foundation". Apple Developer Documentation.
- Douglas Wegscheild, R. Schertler, and Jarkko Hietaniemi, "Time::HiRes". CPAN - Comprehensive Perl Archive Network. 2011. Retrieved 27 October 2011.
- James Britt; Neurogami. "Time class". Ruby-Doc.org: Help and documentation for the Ruby programming language. Scottsdale, AZ. Retrieved 27 October 2011.
- 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.
- "Using the Get-Date Cmdlet". Microsoft Docs. Retrieved 23 July 2019.
- "Windows PowerShell Tip of the Week – Formatting Dates and Times". Microsoft Docs. Retrieved 23 July 2019.
- Critical and Significant Dates, J. R. Stockton (retrieved 3 December 2015)
- The Boost Date/Time Library (C++)
- The Boost Chrono Library (C++)
- The Chronos Date/Time Library (Smalltalk)
- Joda Time, The Joda Date/Time Library (Java)
- The Perl DateTime Project (Perl)
- date: Ruby Standard Library Documentation (Ruby)