Window NT时间
The 18-digit Active Directory timestamps, also named 'Windows NT time format' and 'Win32 FILETIME or SYSTEMTIME'. These are used in Microsoft Active Directory for pwdLastSet, accountExpires, LastLogon, LastLogonTimestamp and LastPwdSet. The timestamp is the number of 100-nanoseconds intervals (1 nanosecond = one billionth of a second) since Jan 1, 1601 UTC.
也就是说,Windows NT时间表示从1602年1月1日UTC时间开始的100纳秒数。引自
网站
,这个网站还提供了在线转换Windows NT时间到人类可读时间的功能。并提供了Windows cmd 和 Power shell转换Windows NT时间的方法,以下(假设当前Windows NT时间为131194973730000000):
command line:
w32tm.exe /ntte 131194973730000000
power shell:
(Get-Date 1/1/1601).AddDays(131194973730000000/864000000000)
这个时间大量用在windows NT操作系统中,我就是在获取注册表项的修改时间是注意到的。
Chrome时间:
准确的说是chrome history time format,被用在chrome记录浏览历史的sqlite文件中,用来记录浏览时间。这个时间是否被用在chrome的其他地方,我目前还不知道,等有时间再深入探讨。它的定义是这样的:
the number of microseconds since January 1, 1601 UTC
与Windows NT时间的起始时间相同,但时间单位不同。
Firefox时间:
同样是Firefox history time format,是Firefox历史记录文件(文件格式同样为sqlite)所使用的时间。定义为:
the number of microseconds since January 1, 1970 UTC
与Chrome时间的单位相同,都为微秒级,但起始时间却与Unix时间相同。
Python时间处理模块:
最后介绍用python处理以上不同时间戳所用到的模块。
关于Unix时间,首推的当然是
time
这个模块,在
这篇文章
有详细介绍,我就不详细展开了。
处理其他时间戳就要用到
datetime
这个模块了。它的基本用法是这样的:
date_string = datetime.
datetime
(
year
,
month
,
day
,
hour=0
,
minute=0
,
second=0
,
microsecond=0
,
tzinfo=None
) +
datetime.
timedelta
(
days=0
,
seconds=0
,
microseconds=0
,
milliseconds=0
,
minutes=0
,
hours=0
,
weeks=0
)
比如计算Windows NT时间、Chrome时间、Firefox时间可以这样(假设Windows NT时间为131194973730000000,chrome时间为13106382734598133,Firefox时间为1461852498963000):
1 import datetime
3 win_nt = datetime.datetime( 1601, 1, 1 ) + datetime.timedelta( microseconds=131194973730000000//10 )
4 chrome = datetime.datetime( 1601, 1, 1 ) + datetime.timedelta( microseconds=13106382734598133 )
5 firefox = datetime.datetime( 1970, 1, 1 ) + datetime.timedelta( microseconds=1461852498963000 )
6 print("Window NT time : " + str(win_nt))
7 print("Chrome time : " + str(chrome))
8 print("Firefox time : " + str(firefox))
Window NT time : 2016-09-28 00:49:33
Chrome time : 2016-04-29 05:52:14.598133
Firefox time : 2016-04-28 14:08:18.963000