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.
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.
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.
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 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 1977scb$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 1978byte , 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] |
() | 1 μs [13] | 1 January 1970 to 7 February 2106 [14] | |
() | 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 |
() | 1 μs | ||
() | 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() |
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] | 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 |
The Windows API, informally WinAPI, is the foundational application programming interface (API) that allows a computer program to access the features of the Microsoft Windows operating system in which the program is running.
Distributed Component Object Model (DCOM) is a proprietary Microsoft technology for communication between software components on networked computers. DCOM, which originally was called "Network OLE", extends Microsoft's COM, and provides the communication substrate under Microsoft's COM+ application server infrastructure.
A Universally Unique Identifier (UUID) is a 128-bit label used for information in computer systems. The term Globally Unique Identifier (GUID) is also used, mostly in Microsoft systems.
In UNIX computing, the system load is a measure of the amount of computational work that a computer system performs. The load average represents the average system load over a period of time. It conventionally appears in the form of three numbers which represent the system load during the last one-, five-, and fifteen-minute periods.
The year 2038 problem is a time computing problem that leaves some computer systems unable to represent times after 03:14:07 UTC on 19 January 2038.
The Common Object File Format (COFF) is a format for executable, object code, and shared library computer files used on Unix systems. It was introduced in Unix System V, replaced the previously used a.out format, and formed the basis for extended specifications such as XCOFF and ECOFF, before being largely replaced by ELF, introduced with SVR4. COFF and its variants continue to be used on some Unix-like systems, on Microsoft Windows, in UEFI environments and in some embedded development systems.
In computing, a hard link is a directory entry that associates a name with a file. Thus, each file must have at least one hard link. Creating additional hard links for a file makes the contents of that file accessible via additional paths. This causes an alias effect: a process can open the file by any one of its paths and change its content. By contrast, a soft link or “shortcut” to a file is not a direct link to the data itself, but rather a reference to a hard link or another soft link.
DIGITAL Command Language (DCL) is the standard command language adopted by many of the operating systems created by Digital Equipment Corporation. DCL had its roots in IAS, TOPS-20, and RT-11 and was implemented as a standard across most of Digital's operating systems, notably RSX-11 and RSTS/E, but took its most powerful form in VAX/VMS. DCL continues to be developed by VSI as part of OpenVMS.
Star Trek is the code name that was given to a secret prototype project, running a port of Macintosh System 7 and its applications on Intel-compatible x86 personal computers. The project, starting in February 1992, was conceived in collaboration between Apple Computer, who provided the majority of engineers, and Novell, who at the time was one of the leaders of cross-platform file-servers. The plan was that Novell would market the resulting OS as a challenge to Microsoft Windows, but the project was discontinued in 1993 and never released, although components were reused in other projects. The project was named after the Star Trek science fiction franchise with the slogan "To boldly go where no Mac has gone before".
In computing, time
is a command in Unix and Unix-like operating systems. It is used to determine the duration of execution of a particular command.
Unix time is a date and time representation widely used in computing. It measures time by the number of non-leap seconds that have elapsed since 00:00:00 UTC on 1 January 1970, the Unix epoch. In modern computing, values are sometimes stored with higher granularity, such as microseconds or nanoseconds.
The Atari TT030 is a member of the Atari ST family, released in 1990. It was originally intended to be a high-end Unix workstation, but Atari took two years to release a port of Unix SVR4 for the TT, which prevented the TT from ever being seriously considered in its intended market.
The proc filesystem (procfs) is a special filesystem in Unix-like operating systems that presents information about processes and other system information in a hierarchical file-like structure, providing a more convenient and standardized method for dynamically accessing process data held in the kernel than traditional tracing methods or direct access to kernel memory. Typically, it is mapped to a mount point named /proc at boot time. The proc file system acts as an interface to internal data structures about running processes in the kernel. In Linux, it can also be used to obtain information about the kernel and to change certain kernel parameters at runtime (sysctl).
The Time Stamp Counter (TSC) is a 64-bit register present on all x86 processors since the Pentium. It counts the number of CPU cycles since its reset. The instruction RDTSC
returns the TSC in EDX:EAX. In x86-64 mode, RDTSC
also clears the upper 32 bits of RAX and RDX. Its opcode is 0F 31
. Pentium competitors such as the Cyrix 6x86 did not always have a TSC and may consider RDTSC
an illegal instruction. Cyrix included a Time Stamp Counter in their MII.
CPU time is the amount of time that a central processing unit (CPU) was used for processing instructions of a computer program or operating system. CPU time is measured in clock ticks or seconds. Sometimes it is useful to convert CPU time into a percentage of the CPU capacity, giving the CPU usage.
In computer science, data type limitations and software bugs can cause errors in time and date calculation or display. These are most commonly manifestations of arithmetic overflow, but can also be the result of other issues. The most well-known consequence of this type is the Y2K problem, but many other milestone dates or times exist that have caused or will cause problems depending on various programming deficiencies.
MS-DOS is an operating system for x86-based personal computers mostly developed by Microsoft. Collectively, MS-DOS, its rebranding as IBM PC DOS, and a few operating systems attempting to be compatible with MS-DOS, are sometimes referred to as "DOS". MS-DOS was the main operating system for IBM PC compatibles during the 1980s, from which point it was gradually superseded by operating systems offering a graphical user interface (GUI), in various generations of the graphical Microsoft Windows operating system.
In computing, an epoch is a fixed date and time used as a reference from which a computer measures system time. Most computer systems determine time as a number representing the seconds removed from a particular arbitrary date and time. For instance, Unix and POSIX measure time as the number of seconds that have passed since Thursday 1 January 1970 00:00:00 UT, a point in time known as the Unix epoch. Windows NT systems, up to and including Windows 11 and Windows Server 2022, measure time as the number of 100-nanosecond intervals that have passed since 1 January 1601 00:00:00 UTC, making that point in time the epoch for those systems. Computing epochs are almost always specified as midnight Universal Time on some particular date.
In computing, a status key is a keyboard key that causes an operating system and/or a program to output status information on a terminal when it is pressed. In the event that a program on a terminal produces no indications that it is running, typing the status key will reveal the program's state and activity. Older implementations produced only a quick one-line status report for the current job when the status key was pressed. Newer implementations support sending a signal to the current process to allow the application to report on status as well.
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.
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.
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.