Convert number of seconds elapsed since 00:00:00, January 1, 1601

J

Jerold Schulman

Anyone know of some freeware I can call to trnaslate the
number of seconds elapsed since 00:00:00, January 1, 1601,
like 127122881993040000, to a date and time?

Something like:

call subroutine pwdLastSetNumber VariableName



Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
D

Dean Wells [MVP]

Jerold said:
Anyone know of some freeware I can call to trnaslate the
number of seconds elapsed since 00:00:00, January 1, 1601,
like 127122881993040000, to a date and time?

Something like:

call subroutine pwdLastSetNumber VariableName



Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com

Windows filetime (a count of 100 nanosecond intervals since the date you
quoted) can be translated on XP or 2003 using -

w32tm /ntte 127122881993040000

Dean
 
M

Matthias Tacke

Jerold said:
Anyone know of some freeware I can call to trnaslate the
number of seconds elapsed since 00:00:00, January 1, 1601,
like 127122881993040000, to a date and time?

Something like:

call subroutine pwdLastSetNumber VariableName
A rough proof returns numbers with only 11 places:

60 sec * 60 min * 24 hours * 365,25 days * 400 years = 12,623,040,000

so Deans answer is quite likely to be more helpful :)
==screen copy=======================================================
C:\test>w32tm /ntte 127122881993040000
147132 23:09:59.3040000 - 2003-11-03 01:09:59 (local time)
C:\test>date /t
2004-05-25

C:\test>time /t
17:37

C:\test>
==screen copy=======================================================
Since the output depends on your date/time format settings and your
time zone I guess you have to fiddle around yourself.
(I'm at gmt+1 and with summer time now gmt+2)
The first number in the output is days elapsed.
 
J

Joe Richards [MVP]

Hey Jerry, that isn't number of seconds, it is number of 100 nanosecond intervals...

You can use repadmin /showtime.

If you want, I have a command line tool laying around somewhere that I could
doll up and put on the joeware site as well if you think it would be useful.


joe
 
J

Joe Richards [MVP]

Ah and here is another post I have reused multiple times....

It gets you to ctime format which you can use various tools to convert to a
string, I have a perl script below to do it.

joe


I have been asked multiple times for this info in newsgroups and emails
to my joeware email and again at work yesterday so I wrote this up.
Thought I would share with the group here in case anyone cares.

---

First off the 64 bit Integer Time Values (Called Integer8) represents
the number of 100 nanosecond intervals between the time stamp and
January 1, 1601. Don't ask me why, this is just what it is, I am not
even going to attempt to explain it other than I wasn't around prior to
1969 so what happened with computers in 1601 is far outside my personal
scope of really caring. In fact I am not sure anything even existed then
because I didn't, it is up for debate.

1. Remove last 7 characters - Usually this will be all zeros but it may
be actual digits if you care to get down to 100 nanosecond accuracy, you
can figure it out.

2. Subtract off 11644473600

You are now at a value that is the number of seconds since since January
1, 1970. Again I will not explain even though I was around then. I still
wasn't at the point that I worried about time stamps on computers, I was
still flabbergasted that man had walked on the moon 6 short months
previously...

This value was targeted because there are functions out there that use
that format for time already and you can leverage them to convert to a
friendly time/date stamp such as ctime or localtime or gmtime.

So how to do this in perl??

Here is a quick perl script:

___t64.pl___
$t64=shift;
$t64=~s/(.+).{7,7}/\1/;
$t64-=11644473600;
($sec, $min, $hour, $mday, $mon, $year, $wday, $ydat,
$isdst)=localtime($t64); $mon++; $year+=1900;
print "$mon/$mday/$year - $hour:$min:$sec DST - $isdst\n";


When you run it it will produce something like:

C:\Temp>t64 127069827243689315
9/2/2003 - 9:25:24 DST - 1


Use as you wish.

For other cool methods to play with those time fields in Perl check out
Robbie Allen's upcoming book - Active Directory Cookbook. :blush:)


joe
 
J

Jerold Schulman

Hey Jerry, that isn't number of seconds, it is number of 100 nanosecond intervals...

You can use repadmin /showtime.

If you want, I have a command line tool laying around somewhere that I could
doll up and put on the joeware site as well if you think it would be useful.


joe


Thanks anyway. I created CvtzFileTime to do it.

@echo off
if {%2}=={} @echo Syntax: call CvtFileTime FT DT&goto :EOF
If "%1" EQU "0" set %2=Never&goto :EOF
for /f "Tokens=3,4 Delims=- " %%a in ('w32tm /ntte %1') do (
set %2=%%a %%b
)



Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top