日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

不同时间戳总结

發(fā)布時(shí)間:2025/4/9 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 不同时间戳总结 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

最近在實(shí)驗(yàn)室?guī)蛶熜肿鲆恍╉?xiàng)目,遇到各種沒見過的時(shí)間戳,在此總結(jié)一下。

?

Unix時(shí)間

關(guān)于這個(gè)時(shí)間,大家一般都比較了解,記錄了從1970年1月1日0時(shí)0分0秒開始到現(xiàn)在的總秒數(shù)。

這篇文章中有關(guān)于Unix時(shí)間和各種常用時(shí)間的關(guān)系,在這里分享一下。

?

Window NT時(shí)間

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時(shí)間表示從1602年1月1日UTC時(shí)間開始的100納秒數(shù)。引自網(wǎng)站,這個(gè)網(wǎng)站還提供了在線轉(zhuǎn)換Windows NT時(shí)間到人類可讀時(shí)間的功能。并提供了Windows cmd 和 Power shell轉(zhuǎn)換Windows NT時(shí)間的方法,以下(假設(shè)當(dāng)前Windows NT時(shí)間為131194973730000000):

command line:

w32tm.exe /ntte 131194973730000000

power shell:

(Get-Date 1/1/1601).AddDays(131194973730000000/864000000000)

這個(gè)時(shí)間大量用在windows NT操作系統(tǒng)中,我就是在獲取注冊(cè)表項(xiàng)的修改時(shí)間是注意到的。

Chrome時(shí)間:

準(zhǔn)確的說是chrome history time format,被用在chrome記錄瀏覽歷史的sqlite文件中,用來記錄瀏覽時(shí)間。這個(gè)時(shí)間是否被用在chrome的其他地方,我目前還不知道,等有時(shí)間再深入探討。它的定義是這樣的:

the number of microseconds since January 1, 1601 UTC

與Windows NT時(shí)間的起始時(shí)間相同,但時(shí)間單位不同。

Firefox時(shí)間:

同樣是Firefox history time format,是Firefox歷史記錄文件(文件格式同樣為sqlite)所使用的時(shí)間。定義為:

the number of microseconds since January 1, 1970 UTC

與Chrome時(shí)間的單位相同,都為微秒級(jí),但起始時(shí)間卻與Unix時(shí)間相同。

Python時(shí)間處理模塊:

最后介紹用python處理以上不同時(shí)間戳所用到的模塊。

?

關(guān)于Unix時(shí)間,首推的當(dāng)然是time這個(gè)模塊,在這篇文章有詳細(xì)介紹,我就不詳細(xì)展開了。

?

處理其他時(shí)間戳就要用到datetime這個(gè)模塊了。它的基本用法是這樣的:

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)

比如計(jì)算Windows NT時(shí)間、Chrome時(shí)間、Firefox時(shí)間可以這樣(假設(shè)Windows NT時(shí)間為131194973730000000,chrome時(shí)間為13106382734598133,Firefox時(shí)間為1461852498963000):

1 import datetime 2 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))

?

結(jié)果為:

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

?

轉(zhuǎn)載于:https://www.cnblogs.com/YoungForest/p/5915074.html

總結(jié)

以上是生活随笔為你收集整理的不同时间戳总结的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。