Skip to content

Instantly share code, notes, and snippets.

@caot
Last active March 4, 2021 03:16
Show Gist options
  • 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
'''
@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