In
computer science
Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to practical disciplines (includin ...
and
computer programming
Computer programming is the process of performing a particular computation (or more generally, accomplishing a specific computing result), usually by designing and building an executable computer program. Programming involves tasks such as anal ...
, 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
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
and
POSIX
The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming inte ...
-compliant systems encode system time ("
Unix time
Current Unix time ()
Unix time is a date and time representation widely used in computing. It measures time by the number of seconds that have elapsed since 00:00:00 UTC on 1 January 1970, the beginning of the Unix epoch, less adjustments ...
") 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 second
A leap second is a one- second adjustment that is occasionally applied to Coordinated Universal Time (UTC), to accommodate the difference between precise time (International Atomic Time (TAI), as measured by atomic clocks) and imprecise observ ...
s. Systems that implement the 32-bit and 64-bit versions of the
Windows API, such as
Windows 9x
Windows 9x is a generic term referring to a series of Microsoft Windows computer operating systems produced from 1995 to 2000, which were based on the Windows 95 kernel and its underlying foundation of MS-DOS, both of which were updated in sub ...
and
Windows NT
Windows NT is a proprietary graphical operating system produced by Microsoft, the first version of which was released on July 27, 1993. It is a processor-independent, multiprocessing and multi-user operating system.
The first version of Wi ...
, 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
Time is the continued sequence of existence and events that occurs in an apparently irreversible succession from the past, through the present, into the future. It is a component quantity of various measurements used to sequence events, t ...
' seconds since the beginning of the epoch translates into the calendar time ''9 September 2001 01:46:40 UT''. Library
subroutines
In computer programming, a function or subroutine is a sequence of program instructions that performs a specific task, packaged as a unit. This unit can then be used in programs wherever that particular task should be performed.
Functions may ...
that handle such conversions may also deal with adjustments for
time zone
A time zone is an area which observes a uniform standard time for legal, commercial and social purposes. Time zones tend to follow the boundaries between countries and their subdivisions instead of strictly following longitude, because i ...
s,
daylight saving time
Daylight saving time (DST), also referred to as daylight savings time or simply daylight time (United States, Canada, and Australia), and summer time (United Kingdom, European Union, and others), is the practice of advancing clocks (typical ...
(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
A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuitry that executes instructions comprising a computer program. The CPU performs basic arithmetic, logic, controlling, and ...
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
Kernel may refer to:
Computing
* Kernel (operating system), the central component of most operating systems
* Kernel (image processing), a matrix used for image convolution
* Compute kernel, in GPGPU programming
* Kernel method, in machine lea ...
code, respectively. Process times are a tally of CPU
instructions or
clock cycles and generally have no direct correlation to
wall time.
File system
In computing, file system or filesystem (often abbreviated to fs) is a method and data structure that the operating system uses to control how data is stored and retrieved. Without a file system, data placed in a storage medium would be one lar ...
s keep track of the times that files are created, modified, and/or accessed by storing
timestamps in the
file control block
A File Control Block (FCB) is a file system structure in which the state of an open file is maintained. A FCB is managed by the operating system, but it resides in the memory of the program that uses the file, not in operating system memory. This ...
(or
inode) of each
file and
directory.
History
Most first-generation
personal computer
A personal computer (PC) is a multi-purpose microcomputer whose size, capabilities, and price make it feasible for individual use. Personal computers are intended to be operated directly by an end user, rather than by a computer expert or tech ...
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 Apple II (stylized as ) is an 8-bit home computer and one of the world's first highly successful mass-produced microcomputer products. It was designed primarily by Steve Wozniak; Jerry Manock developed the design of Apple II's foam-mold ...
, the
BBC Micro
The British Broadcasting Corporation Microcomputer System, or BBC Micro, is a series of microcomputers and associated peripherals designed and built by Acorn Computers in the 1980s for the BBC Computer Literacy Project. Designed with an empha ...
, and the
Commodore PET
The Commodore PET is a line of personal computers produced starting in 1977 by Commodore International. A single all-in-one case combines a MOS Technology 6502 microprocessor, Commodore BASIC in read-only memory, keyboard, monochrome monitor, ...
, among others. Add-on
peripheral boards that included
real-time clock
A real-time clock (RTC) is an electronic device (most often in the form of an integrated circuit) that measures the passage of time.
Although the term often refers to the devices in personal computers, servers and embedded systems, RTCs are ...
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
A motherboard (also called mainboard, main circuit board, mb, mboard, backplane board, base board, system board, logic board (only in Apple computers) or mobo) is the main printed circuit board (PCB) in general-purpose computers and other expand ...
. Prior to the widespread availability of
computer network
A computer network is a set of computers sharing resources located on or provided by network nodes. The computers use common communication protocols over digital interconnections to communicate with each other. These interconnections ar ...
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
A time zone is an area which observes a uniform standard time for legal, commercial and social purposes. Time zones tend to follow the boundaries between countries and their subdivisions instead of strictly following longitude, because i ...
s.
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,
pager
A pager (also known as a beeper or bleeper) is a wireless telecommunications device that receives and displays alphanumeric or voice messages. One-way pagers can only receive messages, while response pagers and two-way pagers can also acknowl ...
s,
cell phones,
fax machines,
telephone answering machines,
camera
A camera is an optical instrument that can capture an image. Most cameras can capture 2D images, with some more advanced models being able to capture 3D images. At a basic level, most cameras consist of sealed boxes (the camera body), with a ...
s,
camcorder
A camcorder is a self-contained portable electronic device with video camera, video and recording as its primary function. It is typically equipped with an articulating screen mounted on the left side, a belt to facilitate holding on the right s ...
s,
central air conditioner
Air conditioning, often abbreviated as A/C or AC, is the process of removing heat from an enclosed space to achieve a more comfortable interior environment (sometimes referred to as 'comfort cooling') and in some cases also strictly controlling ...
s, and
microwave oven
A microwave oven (commonly referred to as a microwave) is an electric oven that heats and cooks food by exposing it to electromagnetic radiation in the microwave frequency range. This induces polar molecules in the food to rotate and produce ...
s.
Microcontroller
A microcontroller (MCU for ''microcontroller unit'', often also MC, UC, or μC) is a small computer on a single VLSI integrated circuit (IC) chip. A microcontroller contains one or more CPUs ( processor cores) along with memory and programma ...
s operating within
embedded system
An embedded system is a computer system—a combination of a computer processor, computer memory, and input/output peripheral devices—that has a dedicated function within a larger mechanical or electronic system. It is ''embedded'' ...
s (such as the
Raspberry Pi
Raspberry Pi () is a series of small single-board computers (SBCs) developed in the United Kingdom by the Raspberry Pi Foundation in association with Broadcom. The Raspberry Pi project originally leaned towards the promotion of teaching basic ...
,
Arduino
Arduino () is an open-source hardware and software company, project, and user community that designs and manufactures single-board microcontrollers and microcontroller kits for building digital devices. Its hardware products are licensed und ...
, 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
In computing and in embedded systems, a programmable interval timer (PIT) is a counter that generates an output signal when it reaches a programmed count. The output signal may trigger an interrupt.
Common features
PITs may be one-shot or periodi ...
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 system
An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
s,
programming language
A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language.
The description of a programming l ...
s, 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 systems
Programming languages and applications
See also
Notes
References
External links
*
Critical and Significant Dates', J. R. Stockton ''(retrieved 3 December 2015)''
*
' (C++)
*
' (C++)
*
The Chronos Date/Time Library' (Smalltalk)
*
Joda Time', The Joda Date/Time Library (Java)
*
The Perl DateTime Project ' (Perl)
*
' (Ruby)
{{DEFAULTSORT:System Time
Operating system technology
Computer programming
Computer real-time clocks