Forked from caot/Active Directory (LDAP) Python Timestamp.py
Created
August 19, 2019 18:29
-
-
Save mariomelofilho/cf7d815300dc306d2c7a2956aa1ce434 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| ''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment