Skip to content

Instantly share code, notes, and snippets.

@benwei
Created January 28, 2016 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save benwei/e28e946c0d284a594b25 to your computer and use it in GitHub Desktop.
Save benwei/e28e946c0d284a594b25 to your computer and use it in GitHub Desktop.
MacOS convert timestamp by date command with GNU bash
#!/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