JRS: In article <***@news.carnet.hr>, dated Wed,
22 Dec 2004 11:10:04, seen in news:microsoft.public.scripting.wsh,
Post by TometaHi!
I need to read and convert date and time stored in registry key
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\NetCache
\Shares\ShareName]
"LastSyncTime"=hex:30,3f,6e,13,99,e6,c4,01 (It is 20.12.2004 14:37)
in readable string.
Anyone knows how to do that?
Dates & times always need to be given a time zone indication.
Reverse the characters, convert to decimal which is in 100 ns units, and
add that to 1601-01-01 00:00:00 GMT.
Stick the following in
<URL:http://www.merlyn.demon.co.uk/js-quick.htm#Ev>,
press Eval, and read the local version of the date/time represented.
Answer = new Date(0x01c4e699136e3f30/1E4 + +new Date(1601,0,1,0,0,0))
I see Mon Dec 20 13:37:40 UTC 2004 - but I'm in England and you are,
presumably, in Croatia where, if you follow EU rules, the time is always
an hour later.
That's javascript. The same basic method should work in VBS, but I do
not know how to do conversion from Hex to number. Well, searching News,
I don't know about long Hex, but, using the VBS button,
Days = (&H01c4e699*&H10000*&H10000 + &H136e3f30)/(1E7*86400)
document.write CDate(DateSerial(1601, 1, 1) + Days)
gives me 2004-12-20 13:37:40 ; I guess that, since zone is disregarded,
you'd get the same GMT time.
There may, of course, be a routine in the WSH language library to do it.
HTH,
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.