Last active
March 5, 2018 17:16
-
-
Save hokie-sam/8dfa60617df750af529fea6b24d14bf9 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
| import time | |
| from datetime import datetime | |
| # It took me a while to figure out to convert | |
| # a string timestamp to the number of seconds | |
| # since the Unix epoch. Turns out it is pretty | |
| # simple. | |
| # Note: it only works for years >= 1900 | |
| my_td_string = 'Date: 2018-01-19 Time: 06:35:30.123' | |
| datetime.strptime(my_td_string, 'Date: %Y-%m-%d Time: %H:%M:%S.%f').timestamp() | |
| # Returns 1516361730.123 | |
| # For a full list of format codes, visit: | |
| # https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment