Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Windows uses January 1, 1601 as starting date.

What does Real time clock use?

If it uses different starting date, does Windows convert its timestamp(because it uses its date and time) into its own? How?

share|improve this question

closed as too localized by Diogo, Simon Sheehan, Tom Wijsman, Linker3000, Randolf Richardson Nov 9 '11 at 1:33

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

add comment

3 Answers

up vote 6 down vote accepted

RTC clock saves its time in battery-backed CMOS memory (nowdays it's just a more integrated chip that emulates older designs). CMOS Memory map is pretty standard on PC-compatible computers. According to these CMOS memory map docs:

 00h Seconds       (BCD 00-59, Hex 00-3B) Note: Bit 7 is read only
 01h Second Alarm  (BCD 00-59, Hex 00-3B; "don't care" if C0-FF)
 02h Minutes       (BCD 00-59, Hex 00-3B)
 03h Minute Alarm  (BCD 00-59, Hex 00-3B; "don't care" if C0-FF))
 04h Hours         (BCD 00-23, Hex 00-17 if 24 hr mode)
                         (BCD 01-12, Hex 01-0C if 12 hr am)
                         (BCD 81-92. Hex 81-8C if 12 hr pm)
 05h Hour Alarm    (same as hours; "don't care" if C0-FF))
 06h Day of Week   (01-07 Sunday=1)
 07h Date of Month (BCD 01-31, Hex 01-1F)
 08h Month         (BCD 01-12, Hex 01-0C)
 09h Year          (BCD 00-99, Hex 00-63)

So it is a straight calendar math to convert these fields to whatever format you fancy: Unix timestamps, DOS-type date/time format, or whatever.

Note that one field lacking from the map above is the time zone and DST setting. So, if you're dual-booting into say Windows and Linux you might have problems. Windows defaults to your local time zone, while Linux usually assumes RTC date/time is UTC (which is more sane in my opinion).

share|improve this answer
    
Yeah, I wish Windows would switch to local time. But you can only imagine the sheer amount of applications this would break. –  surfasb Nov 9 '11 at 4:41
    
@surfasb: Windows can use UTC for the RTC (feature existed in NT 4.0, later added again in 7), and absolutely no program will care. The primary reason it doesn't is to avoid breaking multi-boot setups and OS upgrades. –  grawity Nov 11 '11 at 11:48
add comment

It seems (from osdev and Linux arch/x86/kernel/rtc.c) that the RTC on Intel x86 platform keeps the datetime as separate values for second, minute, hour, and so on.

To get each of the following date/time values from the RTC, you should first verify that Status Register A is not in "update mode" (Bit 7, value = 0x80 is clear). Then select the associated "CMOS register" in the usual way, and read the value from Port 0x71.

Register   Contents
   0       Seconds
   2       Minutes
   4       Hours
   6       Weekday
   7       Day of Month
   8       Month
   9       Year
  0x32     Century (usually)
  0xa      Status Register A
  0xb      Status Register B

The contents of all these registers are converted to a NT or Unix timestamp using advanced mathematics (i.e. addition and multiplication). For a Linux example, see kernel/time.c:mktime in the kernel source.

return ((((unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) + year*365 - 719499)*24 + hour)*60 + min)*60 + sec;

Also, the MSKB article you linked is somewhat out-of-date. Starting with XP, Windows doesn't check the RTC every hour; it uses NTP instead, and writes to the RTC.

share|improve this answer
add comment

a 'Timestamp' (mostly in *nix systems, or any C-like language) usually means the number of seconds since 00:00:00 UTC on January 1, 1970

share|improve this answer
    
i meant timestamp in general, e.g. certain amount of units since certain starting date. –  DrStrangeLove Nov 8 '11 at 15:26
2  
So what exactly is your question? –  Traveling Tech Guy Nov 8 '11 at 15:41
2  
@TravelingTechGuy: As I understand it: "What timestamp format does the hardware clock use, and what date would an all-zeros timestamp represent?" –  grawity Nov 8 '11 at 15:51
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.