Created
January 28, 2016 04:16
-
-
Save benwei/e28e946c0d284a594b25 to your computer and use it in GitHub Desktop.
MacOS convert timestamp by date command with GNU bash
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
#!/bin/bash | |
# author: terry, ben | |
# tested GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin14) | |
# FYR (for Mac OS, may need some change for linux) | |
# second -> ISO8601 | |
date -u -r 1453951368 +%FT%TZ | |
## ouptput: 2016-01-28T03:22:48Z | |
# ISO8601 -> second | |
date -ju -f "%FT%TZ" 2016-01-28T03:22:48Z +%s | |
## output: 1453951368 | |
# current time -> ISO8601 | |
date -u +%FT%TZ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment