Created
November 8, 2022 14:58
-
-
Save oliora/0927422b79cd779768b58b05ee1a9119 to your computer and use it in GitHub Desktop.
Shell timestamp conversion aliases
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
alias to-timesptamp-ms="python3 -c 'import datetime, sys; s = sys.argv[1]; s = s[:-1] if s[-1] == \"Z\" else s; print(round(datetime.datetime.fromisoformat(s).replace(tzinfo=datetime.timezone.utc).timestamp() * 1000))'" | |
alias from-timesptamp-ms="python3 -c 'import datetime, sys; t = int(sys.argv[1]); print(datetime.datetime.utcfromtimestamp(t/1000).strftime(\"%Y-%m-%dT%H:%M:%S.%f\")[:-3]+\"Z\")'"from-timesptamp-ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment