Skip to content

Instantly share code, notes, and snippets.

@caot
Last active March 4, 2021 03:16
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save caot/f57fbf419d6b37d53f6f4a525942cafc to your computer and use it in GitHub Desktop.
Save caot/f57fbf419d6b37d53f6f4a525942cafc to your computer and use it in GitHub Desktop.
from datetime import datetime, timedelta
def to_timestamp(timestamp):
timestamp = float(timestamp[0])
seconds_since_epoch = timestamp/10**7
loc_dt = datetime.fromtimestamp(seconds_since_epoch)
loc_dt -= timedelta(days=(1970 - 1601) * 365 + 89)
return loc_dt
pwdLastSet = result['pwdLastSet']
print pwdLastSet
pwdLastSet_2 = convert_ad_timestamp(pwdLastSet)
print pwdLastSet_2.strftime("%m/%d/%y %H:%M:%S")
print pwdLastSet_2.strftime("%m/%d/%y %I:%M:%S.%f %p")
'''
['131439375892061415']
07/07/17 17:46:29
07/07/17 05:46:29.206141 PM
'''
@caot
Copy link
Author

caot commented Aug 22, 2017

https://www.epochconverter.com/ldap

PS F:> w32tm.exe /ntte 131439375892061415
152128 21:46:29.2061415 - 7/7/2017 5:46:29 PM

@flavienliger
Copy link

I'm a random guy, but thanks for the function !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment