System time
Representation of time used in computers
title: "System time" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["operating-system-technology", "computer-programming", "real-time-clocks"] description: "Representation of time used in computers" topic_path: "general/operating-system-technology" source: "https://en.wikipedia.org/wiki/System_time" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0
::summary Representation of time used in computers ::
::figure[src="https://upload.wikimedia.org/wikipedia/commons/9/90/Unix_time.png" caption="date]]'' command"] ::
In computing, system time represents a computer system's notion of a point in time.
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 , represented as a year/month/day/hour/minute/second/milliseconds value, and , 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 ** 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 problems such as 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
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 the time taken by 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 the current system time
::data[format=table] | UTC | |---| ::
The following tables illustrate methods for retrieving the current 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
::data[format=table]
| Operating system | Command or function | Resolution | Epoch or range |
|---|---|---|---|
| Android | 1 ms | 1 January 1970 | |
| BIOS (IBM PC) | 54.9254 ms | ||
| 18.2065 Hz 16 ticks/hr -- | 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: | ||
| , Days since 31 December 1977 | |||
| , Hour (BCD) | |||
| , Minute (BCD) | |||
| , Second (BCD) | |||
| 1 s | 31 December 1977 to 5 June 2157 | ||
| BDOS function (): | |||
| , Days since 1 January 1978 | |||
| , Hour (BCD) | |||
| , Minute (BCD) | |||
| , Second (BCD) | |||
| DOS (Microsoft) | |||
| 10 ms | 1 January 1980 to 31 December 2099 |
|
| | | |
| macOS, iOS, iPadOS, tvOS, watchOS, visionOS (Apple) | | title= CFRunLoopTimerCreate |url=https://developer.apple.com/documentation/corefoundation/cfrunlooptimercreate(::::::_:) |access-date=5 August 2025 |work=Apple Developer Documentation}}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. | 1 January 2001 ±10,000 years |
| OpenVMS | | 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}} | 17 November 1858 to 31 July 31,086 |
| sh|gettimeofday|SUS | inline}}() | 1 μs | 1 January 1970 to 7 February 2106 |
| sh|clock_gettime|SUS | inline}}() | 1 ns | |
| z/OS | | 2−12 μs
244.14 ps | 1 January 1900 to 17 September 2042 UT |
| | 1 January 1900 to AD 36,765 | | |
| Unix, POSIX
(see also C date and time functions) |
| 1 s | (*)
32-bit [time_t](time-t): 1 January 1970 to 19 January 2038
64-bit [time_t](time-t): 1 January 1970 to 4 December AD 292,277,026,596 |
| sh|gettimeofday|SUS | inline}}() | 1 μs | |
| sh|clock_gettime|SUS | inline}}() | 1 ns | |
| OS/2 | | 10 ms | 1 January 1980 to 31 December 2079 |
| Windows | | 1 ms | 1 January 1601 to 14 September 30828, 02:48:05.4775807 |
| | 100 ns | | |
| | | | |
::
Programming languages and applications
::data[format=table]
| Language/Application | Function or variable | Resolution | Epoch or range |
|---|---|---|---|
| Ada | 100 μs to | ||
| 20 ms (*) | 1 January 1901 to 31 December 2099 (*) | ||
| AWK | 1 s | (*) | |
| BASIC, True BASIC | , | ||
| , | 1 s | (*) | |
| Business BASIC | , | 0.1 s | (*) |
| C (see C date and time functions) | system time values]]. The C++ library encompasses the C library, so it uses the same system time implementation as C. | (*) | |
| C++ | |||
| 1 s (*) | |||
| 1 ns (C++11, OS dependent) | (*) | ||
| C# | |||
| url=https://docs.microsoft.com/en-us/dotnet/api/system.datetime.ticks | title=DateTime.Ticks Property | website=Microsoft Docs}} | 1 January 0001 to 31 December 9999 |
| CICS | 1 ms | 1 January 1900 | |
| COBOL | 1 s | 1 January 1601 | |
| Common Lisp | 1 s | 1 January 1900 | |
| Delphi (Borland) | |||
| 1 ms | |||
| (floating point) | 1 January 1900 | ||
| Delphi | |||
| (Embarcadero Technologies) | 1 ms | 0/0/0000 0:0:0:000 to | |
| 12/31/9999 23:59:59:999 [sic] | |||
| (alias for ) | |||
| 0/0/0000 0:0:0:000 to | |||
| 12/31/9999 0:0:0:000 [sic] | |||
| 1 s | 0/0/0000 0:0:0:000 to | ||
| 12/31/9999 23:59:59:000 [sic] | |||
| 1 day | 1 to 7 | ||
| 1 year | (*) | ||
| Emacs Lisp | 1 μs (*) | 1 January 1970 | |
| Erlang | , | OS dependent, e.g. on Linux 1ns | 1 January 1970 |
| Excel | ? | 0 January 1900 | |
| Fortran | |||
| 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 |
| 1 μs | |||
| Go | 1 ns | 1 January 0001 | |
| Haskell | 1 ps (*) | 1 January 1970 (*) | |
| 1 ps (*) | 17 November 1858 (*) | ||
| java Java | |||
| 1 ms | 1 January 1970 | ||
| 1 ns | arbitrary | ||
| 1 ns | url=https://docs.oracle.com/javase/8/docs/api/java/time/Instant.html | title=JSR-310 Java Time System | |
| JavaScript, TypeScript | |||
| 1 ms | 1 January 1970 | ||
| Julia | Dates.now() | 1 ms | title=Dates |
| Matlab | 1 s | 0 January 0000 | |
| MUMPS | (short for ) | 1 s | 31 December 1840 |
| LabVIEW | 1 ms | 00:00:00.000 1 January 1904 | |
| 1 ms | 00:00:00.000 1 January 1904 | ||
| Objective-C | url=https://developer.apple.com/documentation/foundation/nstimeinterval | work=Apple Developer Documentation | |
| OCaml | 1 s | 1 January 1970 | |
| 1 μs | |||
| Extended Pascal | 1 s | (*) | |
| Turbo Pascal | |||
| 10 ms | (*) | ||
| Perl | 1 s | 1 January 1970 | |
| 1 μs | |||
| PHP | |||
| 1 s | 1 January 1970 | ||
| 1 μs | |||
| PureBasic | 1 s | 1 January 1970 to 19 January 2038 | |
| Python | 1 μs (*) | 1 January 1970 | |
| RPG | , | ||
| , | 1 s | 1 January 0001 to 31 December 9999 | |
| , | 1 μs | ||
| Ruby | 1 μs (*) | 1 January 1970 | |
| (to 19 January 2038 prior to Ruby 1.9.2) | |||
| Scheme | 1 s | 1 January 1900 | |
| Smalltalk | |||
| (VisualWorks) | 1 s (ANSI) | ||
| 1 μs (VisualWorks) | |||
| 1 s (Squeak) | 1 January 1901 (*) |
| (Squeak) | | | | | (Chronos) | | | | | SQL | or or or or | 3 ms | 1 January 1753 to 31 December 9999 () | | 1 min | 1 January 1900 to 6 June 2079 | | | | Standard ML | | 1 μs () | 1 January 1970 () | | Tcl | | 1 s | 1 January 1970 | | | 1 ms | | | | | 1 μs | | | | | 1 μs () | (*) | | | Windows PowerShell | | 100 ns | 1 January 0001 to 31 December 9999 | | | | | | | Visual Basic .NET | | 100 ns | 1 January 0001 to 31 December 9999 | ::
Notes
References
References
- 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".
- "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]].
- (2007). "CFAbsoluteTimeGetCurrent". Apple Developer Documentation.
- "CFRunLoopTimerCreate". Apple Developer Documentation.
- (1991). "VAX/VMS Internals and Data Structures, Version 5.2". Digital Press.
- (1997-07-24). "Why is Wednesday, November 17, 1858 the base time for OpenVMS (VAX VMS)?".
- (November 2020). "VSI C Run-Time Library Reference Manual for OpenVMS Systems". VSI.
- "OpenVMS and the year 2038". HP.
- (2007). "z/Architecture Principles of Operation". International Business Machines.
- 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.
- "Expanded 64-bit time values". IBM.
- Jonathan de Boyne Pollard. "The 32-bit Command Interpreter".
- "DateTime.Now Property".
- "DateTime.UtcNow Property".
- "DateTime.Ticks Property".
- (2013). "Date and Time Support".
- (2013). "System.SysUtils.Time".
- (2013). "System.SysUtils.GetTime".
- (2013). "System.SysUtils.Date".
- (2013). "System.DateUtils.Today".
- (2013). "System.DateUtils.Tomorrow".
- (2013). "System.DateUtils.Yesterday".
- (2013). "System.SysUtils.Now".
- (2013). "System.SysUtils.DayOfWeek".
- (2013). "System.SysUtils.CurrentYear".
- "Time and Time Correction in Erlang".
- (2003). "XL2000: Early Dates on Office Spreadsheet Component Differ from Excel".
- (29 April 2019). "SYSTEM_CLOCK". Intel Fortran Compiler 19.0 Developer Guide and Reference.
- "SYSTEM_CLOCK — Time function". The GNU Fortran Compiler.
- (2015). "System.nanoTime() method". Java Platform, Standard Edition 6: API Specification.
- (2014). "Clock.systemUTC() and other methods". Java Platform, Standard Edition 8: API Specification.
- (2014). "JSR-310 Java Time System". Java Platform, Standard Edition 8: API Specification.
- "Dates".
- "Matlab Help".
- "NSTimeInterval - Foundation". Apple Developer Documentation.
- (2011). "Time::HiRes". CPAN - Comprehensive Perl Archive Network.
- "Time class".
- Yugui. (18 August 2010). "Ruby 1.9.2 is released".
- "MIT/GNU Scheme 9.2: 15.5 Date and Time".
- (22 October 2009). "Using the Get-Date Cmdlet".
- (26 May 2010). "Windows PowerShell Tip of the Week – Formatting Dates and Times".
::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::