Share on Facebook Share on Twitter Email
Answers.com

System time

 
Wikipedia: System time
 

In computer science and computer programming, system time represents a computer system's notion of the passing 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 as the number of seconds elapsed since the start of the epoch at 1970-01-01 00:00:00 Z. Windows NT counts the number of 100-nanosecond ticks since 1601-01-01 00:00:00 Z as reckoned in the proleptic Gregorian calendar, but returns the current time to the nearest millisecond.

Unix date command

System time can be converted into calendar time, which is a form more suitable for human comprehension. For example, the Unix system time that is 1,000,000,000 seconds since the beginning of the epoch translates into the calendar time 2001-09-09 01:46:40 UTC (sans leap seconds). Library subroutines that handle such conversions may also deal with adjustments for timezones, 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.

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.

It should be noted that most first-generation PCs did not keep track of dates and times. These included systems that ran the CP/M operating system, the Apple II, and the Commodore PET, among others. The IBM PC was the first widely available personal computer that came equipped with date/time hardware built into the motherboard, and subsequent add-on peripheral boards included real-time clock chips with on-board battery back-up. 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 other time zones.

With current technology, all modern computers keep track of wall 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.

Contents

Retrieving system time

The following tables illustrate methods for retrieving the system time in various operating systems and programming languages. Note: values marked by (*) are system-dependent and may differ across implementations.

Operating systems

Operating System Command / Function Resolution Epoch / Range
BIOS (IBM PC) INT 1Ah,AH=00h[1] 54.931 ms
18.204 Hz
Midnight of the current day
INT 1Ah,AH=02h[1] 1 s 1980-01-01[2]
DOS (Microsoft) TIME
INT 21h,AH=2Ch[1]
10 ms 1980-01-01 to 2099-12-31
Mac OS (Apple) GetDateTime() 1 s 1904-01-01 to 2040-02-06
OpenVMS (HP) SYS$GETTIM() 100 ns 1858-11-17 to AD 31,086
z/OS (IBM) STCK 2−12 μs
244.14 ps
1900-01-01 to 2042-09-17
Unix, POSIX date
time()
1 s (*)
1970-01-01 to 2038-01-19
1970-01-01 to AD 292,277,026,596
gettimeofday() 1 μs
Windows (Microsoft) GetSystemTime() 1 ms 1601-01-01 to AD 30,828
GetSystemTimeAsFileTime() 100 ns

Programming languages

Programming Language Function / Variable Resolution Epoch / Range
Ada Ada.Calendar.Clock 100 μs to
20 ms (*)
1901-01-01 to 2099-12-31 (*)
AWK systime() 1 s (*)
BASIC, True BASIC DATE, DATE$
TIME, TIME$
1 s (*)
C time() 1 s(*) (*)
C++ std::time() 1 s(*) (*)
C# (Microsoft) System.DateTime.Now[3]
System.DateTime.UtcNow[4]
100 ns [5] 0001-01-01 to 9999-12-31
CICS (IBM) ASKTIME 1 ms 1900-01-01
COBOL FUNCTION CURRENT-DATE 1 s 1601-01-01
Common Lisp (get-universal-time) 1 s 1900-01-01
Delphi (Borland) date
time
1 ms
(floating point)
1900-01-01
FORTRAN TIME
ITIME, IDATE
1 s (*)
Haskell Time.getClockTime 1 μs(*) 1970-01-01(*)
Java (Sun) java.util.Date()
System.currentTimeMillis()
1 ms 1970-01-01
System.nanoTime()[6] 1 μs (*)
JavaScript Date() 1 ms 1970-01-01
MUMPS $H (short for $HOROLOG) 1 s 1840-12-31
Objective-C [NSDate timeIntervalSinceReferenceDate] 1 μs? 2001-01-01
OCaml Unix.time () 1 s 1970-01-01
Unix.gettimeofday () 1 μs
Extended Pascal GetTimeStamp() 1 s (*)
Turbo Pascal GetTime()
GetDate()
10 ms (*)
Perl time() 1 s 1970-01-01
Time::HiRes::time[7] 1 μs
PHP time()
mktime()
1 s 1970-01-01
microtime() 1 μs
Python time.time() 1 μs (*) 1970-01-01
Ruby Time.now()[8] 1 μs (*) 1970-01-01 to 2038-01-19
Smalltalk Time microsecondClock
(VisualWorks)
1 s (ANSI)
1 μs (VisualWorks)
1 s (Squeak)
1901-01-01 (*)
Time totalSeconds
(Squeak)
SystemClock ticksNowSinceSystemClockEpoch
(Chronos)
SQL CURDATE()
CURTIME()
GETDATE()
NOW()
SYSDATE()
3 ms 1753-01-01 to 9999-12-31 (*)
60 s 1900-01-01 to 2079-06-06
Standard ML Time.now () 1 μs(*) 1970-01-01(*)
TCL [clock seconds] 1 s 1970-01-01
[clock milliseconds] 1 ms
[clock microseconds] 1 μs
[clock clicks] 1 μs (*) (*)
Windows PowerShell Get-Date[9] 100 ns [5] 0001-01-01 to 9999-12-31
[DateTime]::Now[3]
[DateTime]::UtcNow[4]
Visual Basic .NET (Microsoft) System.DateTime.Now[3]
System.DateTime.UtcNow[4]
100 ns [5] 0001-01-01 to 9999-12-31

References

  1. ^ a b c Ralf Brown's Interrupt List; online browsable version at [1]
  2. ^ Y2K bug of the original RTC (also known as CMOS) chip here; since about 1998 any BIOS which "sees" century (CMOS register 32h) as '19' while year (CMOS register 09h) is less than '80' will automatically adjust the century upward on boot; as a result it is now impossible to set up the RTC clock before 1980.
  3. ^ a b c System.DateTime.Now at microsoft.com
  4. ^ a b c System.DateTime.UtcNow at microsoft.com
  5. ^ a b c MSDN link to DateTime.Ticks[2]
  6. ^ System.nanoTime() method at java.sun.com
  7. ^ Jarkko Hietaniemi / Time-HiRes - search.cpan.org
  8. ^ Time class at ruby-doc.org
  9. ^ Get-Date

See also

External links


Search unanswered questions...
Enter a word or phrase...
All Community Q&A Reference topics
 
 

 

Copyrights:

Wikipedia. This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article "System time" Read more

 

Mentioned in