Created
February 11, 2016 01:11
-
-
Save wonkoderverstaendige/39961960a91c844cdbcb to your computer and use it in GitHub Desktop.
Unix time stamp and back
This file contains 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
import datetime | |
import time | |
dt = datetime.datetime.now() | |
# datetime.datetime(2016, 2, 11, 2, 8, 51, 160960) | |
du = time.mktime(dt.timetuple()) + dt.microsecond*1e-6 | |
# 1455152931.16096 | |
dt2 = datetime.datetime.utcfromtimestamp(du) | |
# datetime.datetime(2016, 2, 11, 1, 8, 51, 160960) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment