convert 64 bit windows date time in python

后端 未结 2 621
灰色年华
灰色年华 2020-12-20 01:17

I need to convert a windows hex 64 bit (big endian) date time to something readable in python?

example \'01cb17701e9c885a\'

converts to \"Tue, 29 June 2010 0

2条回答
  •  忘掉有多难
    2020-12-20 01:55

    Looks like a Win32 FILETIME value, which:

    Contains a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).

    To convert:

    from datetime import datetime,timedelta
    dt = '01cb17701e9c885a'
    us = int(dt,16) / 10.
    print datetime(1601,1,1) + timedelta(microseconds=us)
    

    Output

    2010-06-29 09:47:42.754212
    

提交回复
热议问题