Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

System time

From Wikipedia, the free encyclopedia
(Redirected fromDate (command))
Representation of time used in computers
"System clock" redirects here and is not to be confused withClock generator,Clock signal, orClock rate.
Unixdate command

Incomputer science andcomputer programming,system time represents a computer system's notion of the passage of time. In this sense,time also includes the passing ofdays on the calendar.

System time is measured by asystem clock, which is typically implemented as a simple count of the number ofticks that have transpired since some arbitrary starting date, called theepoch. For example,Unix andPOSIX-compliant systems encode system time ("Unix time") as the number of seconds elapsed since the start of theUnix epoch at 1 January 1970 00:00:00UT, with exceptions forleap seconds. Systems that implement the 32-bit and 64-bit versions of theWindows API, such asWindows 9x andWindows NT, provide the system time as bothSYSTEMTIME, represented as a year/month/day/hour/minute/second/milliseconds value, andFILETIME, represented as a count of the number of 100-nanosecond ticks since 1 January 1601 00:00:00 UT as reckoned in theproleptic Gregorian calendar.

System time can be converted intocalendar time, which is a form more suitable for human comprehension. For example, theUnix system time1000000000 seconds since the beginning of the epoch translates into the calendar time9 September 2001 01:46:40 UT. Librarysubroutines that handle such conversions may also deal with adjustments fortime zones,daylight saving time (DST), leap seconds, and the user'slocale 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 impendingYear 2038 problem. These time values will overflow ("run out of bits") after the end of their system time epoch, leading tosoftware and hardware errors. These systems will require some form of remediation, similar to efforts required to solve the earlierYear 2000 problem. This will also be a potentially much larger problem for existingdata file formats that contain system timestamps stored as 32-bit values.

Other time measurements

[edit]

Closely related to system time isprocess time, which is a count of the totalCPU time consumed by an executingprocess. It may be split intouser andsystem CPU time, representing the time spent executing user code and systemkernel code, respectively. Process times are a tally of CPUinstructions orclock cycles and generally have no direct correlation towall time.

File systems keep track of the times that files are created, modified, and/or accessed by storingtimestamps in thefile control block (orinode) of eachfile anddirectory.

History

[edit]

Most first-generationpersonal computers did not keep track of dates and times. These included systems that ran theCP/M operating system, as well as early models of theApple II, theBBC Micro, and theCommodore PET, among others. Add-onperipheral boards that includedreal-time clock chips with on-boardbattery back-up were available for theIBM PC andXT, but theIBM AT was the first widely available PC that came equipped with date/time hardware built into themotherboard. Prior to the widespread availability ofcomputer networks, most personal computer systems that did track system time did so only with respect tolocal time and did not make allowances for differenttime zones.

With current technology, most modern computers keep track of local civil time, as do many other household and personal devices such asVCRs,DVRs,cable TV receivers,PDAs,pagers,cell phones,fax machines,telephone answering machines,cameras,camcorders,central air conditioners, andmicrowave ovens.

Microcontrollers operating withinembedded systems (such as theRaspberry Pi,Arduino, and othersimilar 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 uponrebooting by obtaining the current time from an external source, such as from atime server or external clock, or byprompting the user to manually enter the current time.

Implementation

[edit]

Thesystem clock is typically implemented as aprogrammable 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

[edit]
12 May 2025 08:08:11 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 variousoperating systems,programming languages, andapplications. Values marked by (*) are system-dependent and may differ across implementations. All dates are given asGregorian orproleptic Gregorian calendar dates.

Theresolution of an implementation's measurement of time does not imply the sameprecision 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

[edit]
Operating systemCommand or functionResolutionEpoch or range
Androidjava.lang.System.currentTimeMillis()1 ms1 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 sMidnight of the current day
INT 1Ah, AH=04h[3]1 day1 January 1980 to 31 December 1999 or 31 December 2079 (system dependent)
CP/M PlusSystem Control Block:[4]
scb$base+58h, Days since 31 December 1977
scb$base+5Ah, Hour (BCD)
scb$base+5Bh, Minute (BCD)
scb$base+5Ch, Second (BCD)
1 s31 December 1977 to 5 June 2157
BDOS function69h> (T_GET):[5]
word, Days since 1 January 1978
byte, Hour (BCD)
byte, Minute (BCD)
byte, Second (BCD)
DOS (Microsoft)C:\>DATE
C:\>TIME
10 ms1 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 ms1 January 2001 ±10,000 years
macOSCFAbsoluteTimeGetCurrent()[9]< 1 ms[10][note 1]1 January 2001 ±10,000 years[10][note 1]
OpenVMSSYS$GETTIM()100 ns[11]17 November 1858 to 31 July 31,086[12]
gettimeofday()1μs[13]1 January 1970 to 7 February 2106[14]
clock_gettime()1ns[13]
z/OSSTCK[15]: 7–187 2−12 μs
244.14 ps[15]: 4–45, 4–46 
1 January 1900 to 17 September 2042 UT[16]
STCKE1 January 1900 to AD 36,765[17]
Unix,POSIX
(see alsoC date and time functions)
$date
time()
1 s(*)
1 January 1970 (to19 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/2DosGetDateTime()10 ms1 January 1980 to 31 December 2079[18]
WindowsGetSystemTime()1 ms1 January 1601 to 14 September 30828, 02:48:05.4775807
GetSystemTimeAsFileTime()100 ns
GetSystemTimePreciseAsFileTime()

Programming languages and applications

[edit]
Language/ApplicationFunction or variableResolutionEpoch or range
AdaAda.Calendar.Clock100 μs to
20 ms (*)
1 January 1901 to 31 December 2099 (*)
AWKsystime()1 s(*)
BASIC,True BASICDATE,DATE$
TIME,TIME$
1 s(*)
Business BASICDAY,TIM0.1 s(*)
C (seeC 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
CICSASKTIME1 ms1 January 1900
COBOLFUNCTION CURRENT-DATE1 s1 January 1601
Common Lisp(get-universal-time)1 s1 January 1900
Delphi (Borland)date
time
1 ms
(floating point)
1 January 1900
Delphi
(Embarcadero Technologies)[22]
System.SysUtils.Time[23]1 ms0/0/0000 0:0:0:000 to
12/31/9999 23:59:59:999 [sic]
System.SysUtils.GetTime[24] (alias forSystem.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 s0/0/0000 0:0:0:000 to
12/31/9999 23:59:59:000 [sic]
System.SysUtils.DayOfWeek[30]1 day1 to 7
System.SysUtils.CurrentYear[31]1 year(*)
Emacs Lisp(current-time)1 μs (*)1 January 1970
Erlangerlang:system_time(),os:system_time()[32]OS dependent, e.g. onLinux 1ns[32]1 January 1970[32]
Exceldate()?0 January 1900[33]
FortranDATE_AND_TIME
SYSTEM_CLOCK
(*)[34]

[35]

1 January 1970
CPU_TIME1 μs
Gotime.Now()1 ns1 January 0001
HaskellTime.getClockTime1 ps (*)1 January 1970 (*)
Data.Time.getCurrentTime1 ps (*)17 November 1858 (*)
Javajava.util.Date()
System.currentTimeMillis()
1 ms1 January 1970
System.nanoTime()[36]1 nsarbitrary[36]
Clock.systemUTC()[37]1 nsarbitrary[38]
JavaScript,TypeScript(new Date()).getTime()
Date.now()
1 ms1 January 1970
Matlabnow1 s0 January 0000[39]
MUMPS$H (short for$HOROLOG)1 s31 December 1840
LabVIEWTick Count1 ms00:00:00.000 1 January 1904
Get Date/Time in Seconds1 ms00:00:00.000 1 January 1904
Objective-C[NSDate timeIntervalSinceReferenceDate]< 1 ms[40]1 January 2001 ±10,000 Years[40]
OCamlUnix.time()1 s1 January 1970
Unix.gettimeofday()1 μs
Extended PascalGetTimeStamp()1 s(*)
Turbo PascalGetTime()
GetDate()
10 ms(*)
Perltime()1 s1 January 1970
Time::HiRes::time[41]1 μs
PHPtime()
mktime()
1 s1 January 1970
microtime()1 μs
PureBasicDate()1 s1 January 1970 to 19 January 2038
Pythondatetime.now().timestamp()1 μs (*)1 January 1970
RPGCURRENT(DATE),%DATE
CURRENT(TIME),%TIME
1 s1 January 0001 to 31 December 9999
CURRENT(TIMESTAMP),%TIMESTAMP1 μs
RubyTime.now()[42]1 μs (*)1 January 1970
(to 19 January 2038 prior to Ruby 1.9.2[43])
Scheme(get-universal-time)[44]1 s1 January 1900
SmalltalkTime microsecondClock
(VisualWorks)
1 s(ANSI)
1 μs(VisualWorks)
1 s(Squeak)
1 January 1901 (*)
Time totalSeconds
(Squeak)
SystemClock ticksNowSinceSystemClockEpoch
(Chronos)
SQLCURDATE() orCURRENT DATE
CURTIME() orCURRENT TIME
GETDATE() orGETUTCDATE()
NOW() orCURRENT TIMESTAMP
SYSDATE()
3 ms1 January 1753 to 31 December 9999 (*)
60 s1 January 1900 to 6 June 2079
Standard MLTime.now()1 μs (*)1 January 1970 (*)
TCL[clock seconds]1 s1 January 1970
[clock milliseconds]1 ms
[clock microseconds]1 μs
[clock clicks]1 μs (*)(*)
Windows PowerShellGet-Date[45][46]100 ns[21]1 January 0001 to 31 December 9999
[DateTime]::Now[19]
[DateTime]::UtcNow[20]
Visual Basic .NETSystem.DateTime.Now[19]
System.DateTime.UtcNow[20]
100 ns[21]1 January 0001 to 31 December 9999

See also

[edit]

Notes

[edit]
  1. ^abThe 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 typeNSTimeInterval appears to be interchangeable, and has the precision and range listed.
  2. ^abcdTheC standard library does not specify any specific resolution, epoch, range, or datatype forsystem time values. The C++ library encompasses the C library, so it uses the same system time implementation as C.

References

[edit]
  1. ^Ralf D. Brown (2000)."Int 0x1A, AH=0x00".Ralf Brown's Interrupt List.
  2. ^Ralf D. Brown (2000)."Int 0x1A, AH=0x02".Ralf Brown's Interrupt List.
  3. ^Ralf D. Brown (2000)."Int 0x1A, AH=0x04".Ralf Brown's Interrupt List.
  4. ^"CP/M Plus (CP/M Version 3.0) Operating System Guide"(PDF).
  5. ^"BDOS system calls".
  6. ^Ralf D. Brown (2000)."Int 0x21, AH=0x2c".Ralf Brown's Interrupt List.
  7. ^Ralf D. Brown (2000)."Int 0x21, AH=0x2a".Ralf Brown's Interrupt List.
  8. ^"Time Utilities Reference".iOS Developer Library. 2007.
  9. ^"Time Utilities Reference".Mac OS X Developer Library. 2007.
  10. ^ab"Time Utilities - Foundation".Apple Developer Documentation. Retrieved6 July 2022.
  11. ^Ruth E. Goldenberg; Lawrence J. Kenah; Denise E. Dumas (1991).VAX/VMS Internals and Data Structures, Version 5.2. Digital Press.ISBN 978-1555580599.
  12. ^"Why is Wednesday, November 17, 1858 the base time for OpenVMS (VAX VMS)?".Stanford University. 24 July 1997.Archived from the original on 24 July 1997. Retrieved8 January 2020.
  13. ^ab"VSI C Run-Time Library Reference Manual for OpenVMS Systems"(PDF). VSI. November 2020. Retrieved2021-04-17.
  14. ^"OpenVMS and the year 2038". HP. Retrieved2021-04-17.
  15. ^abz/Architecture Principles of Operation(PDF). Poughkeepsie, New York: International Business Machines. 2007.
  16. ^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.
  17. ^"Expanded 64-bit time values". IBM. Retrieved2021-04-18.
  18. ^Jonathan de Boyne Pollard."The 32-bit Command Interpreter".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.
  19. ^abc"DateTime.Now Property".Microsoft Docs.
  20. ^abc"DateTime.UtcNow Property".Microsoft Docs.
  21. ^abc"DateTime.Ticks Property".Microsoft Docs.
  22. ^"Date and Time Support".Embarcadero Developer Network. 2013.
  23. ^"System.SysUtils.Time".Embarcadero Developer Network. 2013.
  24. ^"System.SysUtils.GetTime".Embarcadero Developer Network. 2013.
  25. ^"System.SysUtils.Date".Embarcadero Developer Network'. 2013.
  26. ^"System.DateUtils.Today".Embarcadero Developer Network. 2013.
  27. ^"System.DateUtils.Tomorrow".Embarcadero Developer Network. 2013.
  28. ^"System.DateUtils.Yesterday".Embarcadero Developer Network. 2013.
  29. ^"System.SysUtils.Now".Embarcadero Developer Network. 2013.
  30. ^"System.SysUtils.DayOfWeek".Embarcadero Developer Network. 2013.
  31. ^"System.SysUtils.CurrentYear".Embarcadero Developer Network. 2013.
  32. ^abc"Time and Time Correction in Erlang".www.erlang.org.
  33. ^"XL2000: Early Dates on Office Spreadsheet Component Differ from Excel".Microsoft Support. 2003. Archived fromthe original on 24 October 2007.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.
  34. ^"SYSTEM_CLOCK".Intel Fortran Compiler 19.0 Developer Guide and Reference. 29 April 2019. Retrieved23 July 2019.
  35. ^"SYSTEM_CLOCK — Time function".The GNU Fortran Compiler. Retrieved27 October 2011.
  36. ^ab"System.nanoTime() method".Java Platform, Standard Edition 6: API Specification. 2015. Retrieved23 July 2019.
  37. ^"Clock.systemUTC() and other methods".Java Platform, Standard Edition 8: API Specification. 2014. Retrieved15 January 2015.
  38. ^"JSR-310 Java Time System".Java Platform, Standard Edition 8: API Specification. 2014. Retrieved15 January 2015.
  39. ^"Matlab Help".
  40. ^ab"NSTimeInterval - Foundation".Apple Developer Documentation.
  41. ^Douglas Wegscheild, R. Schertler, and Jarkko Hietaniemi,"Time::HiRes".CPAN - Comprehensive Perl Archive Network. 2011. Retrieved27 October 2011.
  42. ^"Time class".
  43. ^Yugui (18 August 2010)."Ruby 1.9.2 is 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.
  44. ^"MIT/GNU Scheme 9.2: 15.5 Date and Time".
  45. ^"Using the Get-Date Cmdlet".Microsoft Docs. 22 October 2009. Retrieved23 July 2019.
  46. ^"Windows PowerShell Tip of the Week – Formatting Dates and Times".Microsoft Docs. 26 May 2010. Retrieved23 July 2019.

External links

[edit]
Key concepts
Measurement
andstandards
Chronometry
Measurement
systems
Calendars
Clocks
Philosophy of time
Human experience
anduse of time
Time inscience
Geology
Physics
Other fields
Related
International standards
template illustration
template illustration
Obsolete standards
Time in physics
Horology
Calendar
Archaeology and geology
Astronomical chronology
Otherunits of time
Related topics
Retrieved from "https://en.wikipedia.org/w/index.php?title=System_time&oldid=1287765920#Retrieving_system_time"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp