System time

Short description: Representation of time used in computers

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.

## Contents

* 1 Other time measurements
* 2 History
* 3 Implementation
* 4 Retrieving system time
* 4.1 Operating systems
* 4.2 Programming languages and applications
* 5 See also
* 6 Notes
* 7 References
* 8 External links

## 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.

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

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

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

02 August 2026 11:49:35 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

Operating system  | Command or function  | Resolution | Epoch or range

|
|
|

Android | `java.lang``.System.currentTimeMillis()` | 1 ms  | 1 January 1970
BIOS (IBM PC)  | 54.9254 ms
18.2065 Hz  | Midnight of the current day
1 s  | Midnight of the current day
1 day  | 1 January 1980 to 31 December 1999 or 31 December 2079 (system dependent)
CP/M Plus  | System Control Block:[1]
`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`):[2]
`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
iOS (Apple)  | `CFAbsoluteTimeGetCurrent()`[3] | < 1 ms  | 1 January 2001 ±10,000 years
macOS | `CFAbsoluteTimeGetCurrent()`[4] | < 1 ms[5][note 1] | 1 January 2001 ±10,000 years[5][note 1]
OpenVMS | `SYS$GETTIM()` | 100 ns[6] | 17 November 1858 to 31 July 31,086[7]
`gettimeofday`() | 1 μs[8] | 1 January 1970 to 7 February 2106[9]
`clock_gettime`() | 1 ns[8]
z/OS  | `STCK`[10]: 7–187 | 2−12 μs
244.14 ps[10]: 4–45, 4–46 | 1 January 1900 to 17 September 2042 UT[11]
`STCKE` | 1 January 1900 to AD 36,765[12]
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[13]
Windows | `GetSystemTime()` | 1 ms  | 1 January 1601 to 14 September 30828, 02:48:05.4775807
`GetSystemTimeAsFileTime()` | 100 ns
`GetSystemTimePreciseAsFileTime()`

### 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 (*)
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`[14]
`System.DateTime.UtcNow`[15] | 100 ns[16] | 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)[17] | `System.SysUtils.Time`[18] | 1 ms  | 0/0/0000 0:0:0:000 to
12/31/9999 23:59:59:999 [sic]
`System.SysUtils.GetTime`[19] (alias for `System.SysUtils.Time`)
`System.SysUtils.Date`[20] | 0/0/0000 0:0:0:000 to
12/31/9999 0:0:0:000 [sic]
`System.DateUtils.Today`[21]
`System.DateUtils.Tomorrow`[22]
`System.DateUtils.Yesterday`[23]
`System.SysUtils.Now`[24] | 1 s  | 0/0/0000 0:0:0:000 to
12/31/9999 23:59:59:000 [sic]
`System.SysUtils.DayOfWeek`[25] | 1 day  | 1 to 7
`System.SysUtils.CurrentYear`[26] | 1 year  | (*)
Emacs Lisp | `(current-time)` | 1 μs (*)  | 1 January 1970
Erlang | `erlang:system_time()`, `os:system_time()`[27] | OS dependent, e.g. on Linux 1ns[27] | 1 January 1970[27]
Excel | `date()` | ?  | 0 January 1900[28]
Fortran | `DATE_AND_TIME`
`SYSTEM_CLOCK` | (*)[29]

[30]

| 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()`[31] | 1 ns  | arbitrary[31]
`Clock.systemUTC()`[32] | 1 ns  | arbitrary[33]
JavaScript, TypeScript | `(new Date()).getTime()`
`Date.now()` | 1 ms  | 1 January 1970
Matlab  | `now` | 1 s  | 0 January 0000[34]
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[35] | 1 January 2001 ±10,000 Years[35]
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`[36] | 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)`, `�TE`
`CURRENT(TIME)`, `%TIME` | 1 s  | 1 January 0001 to 31 December 9999
`CURRENT(TIMESTAMP)`, `%TIMESTAMP` | 1 μs
Ruby | `Time.now()`[37] | 1 μs (*)  | 1 January 1970
(to 19 January 2038 prior to Ruby 1.9.2[38])
Scheme | `(get-universal-time)`[39] | 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`[40][41] | 100 ns[16] | 1 January 0001 to 31 December 9999
`[DateTime]::Now`[14]
`[DateTime]::UtcNow`[15]
Visual Basic .NET | `System.DateTime.Now`[14]
`System.DateTime.UtcNow`[15] | 100 ns[16] | 1 January 0001 to 31 December 9999

## See also

* Calendar
* DATE (command)
* Epoch
* GPS time
* Jiffy
* Network Time Protocol
* rdate
* TIME (command)
* time.h
* time t
* Time formatting and storage bugs
* Time Protocol
* Time standard
* Timestamp
* Unix date command
* Unix time
* Unix time command
* Elapsed real time
* Year 2000 problem
* Year 2038 problem

## Notes

1. ↑ 1.0 1.1 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. ↑ 2.0 2.1 2.2 2.3 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

1. ↑ "CP/M Plus (CP/M Version 3.0) Operating System Guide". http://www.cpm.z80.de/manuals/cpm3-sys.pdf.
2. ↑ "BDOS system calls". http://www.seasip.info/Cpm/bdos.html#105.
3. ↑ "Time Utilities Reference". iOS Developer Library. 2007. https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFTimeUtils/Reference/reference.html#//apple_ref/doc/c_ref/CFAbsoluteTimeGetCurrent.
4. ↑ "Time Utilities Reference". Mac OS X Developer Library. 2007. https://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFTimeUtils/Reference/reference.html.
5. ↑ 5.0 5.1 "Time Utilities - Foundation". Apple Developer Documentation. https://developer.apple.com/documentation/corefoundation/time_utilities.
6. ↑ Ruth E. Goldenberg; Lawrence J. Kenah; Denise E. Dumas (1991). VAX/VMS Internals and Data Structures, Version 5.2. Digital Press. ISBN 978-1555580599. https://books.google.com/books?id=D7xQAAAAMAAJ.
7. ↑ "Why is Wednesday, November 17, 1858 the base time for OpenVMS (VAX VMS)?". 1997-07-24. https://www.slac.stanford.edu/~rkj/crazytime.txt.
8. ↑ 8.0 8.1 "VSI C Run-Time Library Reference Manual for OpenVMS Systems". VSI. November 2020. https://vmssoftware.com/docs/VSI_CRTL_REF.pdf.
9. ↑ "OpenVMS and the year 2038". HP. https://www.zx.net.nz/mirror/h71000.www7.hp.com/2038.html.
10. ↑ 10.0 10.1 z/Architecture Principles of Operation. Poughkeepsie, New York: International Business Machines. 2007. http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/download/A2278325.pdf?DT=20070807125005&XKS=DZ9ZBK07.
11. ↑ 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.
12. ↑ "Expanded 64-bit time values". IBM. https://www.ibm.com/docs/en/zos/2.4.0?topic=addressing-expanded-64-bit-time-values.
13. ↑ Jonathan de Boyne Pollard. "The 32-bit Command Interpreter". https://jdebp.eu/Softwares/cmd.html. "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."
14. ↑ 14.0 14.1 14.2 "DateTime.Now Property". https://docs.microsoft.com/en-us/dotnet/api/system.datetime.now.
15. ↑ 15.0 15.1 15.2 "DateTime.UtcNow Property". https://docs.microsoft.com/en-us/dotnet/api/system.datetime.utcnow.
16. ↑ 16.0 16.1 16.2 "DateTime.Ticks Property". https://docs.microsoft.com/en-us/dotnet/api/system.datetime.ticks.
17. ↑ "Date and Time Support". 2013. http://docwiki.embarcadero.com/RADStudio/XE4/en/Date_and_Time_Support.
18. ↑ "System.SysUtils.Time". 2013. http://docwiki.embarcadero.com/Libraries/XE4/en/System.SysUtils.Time.
19. ↑ "System.SysUtils.GetTime". 2013. http://docwiki.embarcadero.com/Libraries/XE4/en/System.SysUtils.GetTime.
20. ↑ "System.SysUtils.Date". 2013. http://docwiki.embarcadero.com/Libraries/XE4/en/System.SysUtils.Date.
21. ↑ "System.DateUtils.Today". 2013. http://docwiki.embarcadero.com/Libraries/XE4/en/System.DateUtils.Today.
22. ↑ "System.DateUtils.Tomorrow". 2013. http://docwiki.embarcadero.com/Libraries/XE4/en/System.DateUtils.Tomorrow.
23. ↑ "System.DateUtils.Yesterday". 2013. http://docwiki.embarcadero.com/Libraries/XE4/en/System.DateUtils.Yesterday.
24. ↑ "System.SysUtils.Now". 2013. http://docwiki.embarcadero.com/Libraries/XE4/en/System.SysUtils.Now.
25. ↑ "System.SysUtils.DayOfWeek". 2013. http://docwiki.embarcadero.com/Libraries/XE4/en/System.SysUtils.DayOfWeek.
26. ↑ "System.SysUtils.CurrentYear". 2013. http://docwiki.embarcadero.com/Libraries/XE4/en/System.SysUtils.CurrentYear.
27. ↑ 27.0 27.1 27.2 "Time and Time Correction in Erlang". https://www.erlang.org/doc/apps/erts/time_correction.html.
28. ↑ "XL2000: Early Dates on Office Spreadsheet Component Differ from Excel". 2003. http://support.microsoft.com/kb/205719. "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."
29. ↑ "SYSTEM_CLOCK". Intel Fortran Compiler 19.0 Developer Guide and Reference. 29 April 2019. https://software.intel.com/en-us/fortran-compiler-developer-guide-and-reference-system-clock.
30. ↑ "SYSTEM_CLOCK — Time function". The GNU Fortran Compiler. https://gcc.gnu.org/onlinedocs/gfortran/SYSTEM_005fCLOCK.html.
31. ↑ 31.0 31.1 "System.nanoTime() method". Java Platform, Standard Edition 6: API Specification. 2015. https://docs.oracle.com/javase/6/docs/api/java/lang/System.html#nanoTime().
32. ↑ "Clock.systemUTC() and other methods". Java Platform, Standard Edition 8: API Specification. 2014. https://docs.oracle.com/javase/8/docs/api/java/time/Clock.html#systemUTC--.
33. ↑ "JSR-310 Java Time System". Java Platform, Standard Edition 8: API Specification. 2014. https://docs.oracle.com/javase/8/docs/api/java/time/Instant.html.
34. ↑ "Matlab Help". http://www.mathworks.com/help/matlab/ref/datenum.html.
35. ↑ 35.0 35.1 "NSTimeInterval - Foundation". Apple Developer Documentation. https://developer.apple.com/documentation/foundation/nstimeinterval.
36. ↑ Douglas Wegscheild, R. Schertler, and Jarkko Hietaniemi, "Time::HiRes". CPAN - Comprehensive Perl Archive Network. 2011. https://metacpan.org/module/Time::HiRes.
37. ↑ "Time class". Scottsdale, AZ. https://ruby-doc.org/core/Time.html.
38. ↑ Yugui (18 August 2010). "Ruby 1.9.2 is released". https://www.ruby-lang.org/en/news/2010/08/18/ruby-1-9-2-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."
39. ↑ "MIT/GNU Scheme 9.2: 15.5 Date and Time". https://edoras.sdsu.edu/doc/mit-scheme-9.2/mit-scheme-ref/Date-and-Time.html.
40. ↑ "Using the Get-Date Cmdlet". https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-powershell-1.0/ee176845(v=technet.10).
41. ↑ "Windows PowerShell Tip of the Week – Formatting Dates and Times". https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-powershell-1.0/ee692801(v=technet.10).

## External links

* 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)

* v
* t
* e

Time measurement and standards

* Chronometry
* Orders of magnitude
* Metrology

International standards|

* Coordinated Universal Time
* offset
* UT
* ΔT
* DUT1
* International Earth Rotation and Reference Systems Service
* ISO 31-1
* ISO 8601
* International Atomic Time
* 6-hour clock (Italian · Thai)
* 12-hour clock
* 24-hour clock
* Barycentric Coordinate Time
* Barycentric Dynamical Time
* Civil time
* Daylight saving time
* Geocentric Coordinate Time
* International Date Line
* Leap second
* Solar time
* Terrestrial Time
* Time zone
* 180th meridian

Obsolete standards|

* Ephemeris time
* Greenwich Mean Time
* Prime meridian

Time in physics|

* Absolute space and time
* Spacetime
* Chronon
* Continuous signal
* Coordinate time
* Cosmological decade
* Discrete time and continuous time
* Planck time
* Proper time
* Theory of relativity
* Time dilation
* Gravitational time dilation
* Time domain
* Time translation symmetry
* T-symmetry

Horology|

* Clock
* Astrarium
* Atomic clock
* Complication
* History of timekeeping devices
* Hourglass
* Marine chronometer
* Marine sandglass
* Radio clock
* Watch
* stopwatch
* Water clock
* Sundial
* Dialing scales
* Equation of time
* History of sundials
* Sundial markup schema

Calendar|

* Astronomical
* Dominical letter
* Epact
* Equinox
* Gregorian
* Hebrew
* Hindu
* Holocene
* Intercalation
* Islamic
* Julian
* Leap year
* Lunar
* Lunisolar
* Solar
* Solstice
* Tropical year
* Weekday determination
* Weekday names

Archaeology and geology|

* Chronological dating
* Geologic time scale
* International Commission on Stratigraphy

Astronomical chronology|

* Galactic year
* Nuclear timescale
* Precession
* Sidereal time

Other units of time|

* Flick
* Shake
* Jiffy
* Second
* Minute
* Moment
* Hour
* Day
* Week
* Fortnight
* Month
* Year
* Olympiad
* Lustrum
* Decade
* Century
* Saeculum
* Millennium

Related topics|

* Chronology
* Duration
* music
* Mental chronometry
* Decimal time
* Metric time
* System time
* Time value of money
* Timekeeper

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/System time. Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=System_time&oldid=204727"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template