Created
March 11, 2017 17:12
-
-
Save aculich/a2dbca090bd774ec4f66f7d9cb67c4bc to your computer and use it in GitHub Desktop.
reference for most commonly requested bash timestamps
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 | |
| ## Taken from: | |
| ## https://zxq9.com/archives/795 | |
| # reference for most commonly requested bash timestamps | |
| cat << EOD | |
| Format/result | Command | Output | |
| ------------------------------+----------------------------+------------------------------ | |
| YY-MM-DD_hh:mm:ss | date +%F_%T | $(date +%F_%T) | |
| YYMMDD_hhmmss | date +%Y%m%d_%H%M%S | $(date +%Y%m%d_%H%M%S) | |
| YYMMDD_hhmmss (UTC version) | date --utc +%Y%m%d_%H%M%SZ | $(date --utc +%Y%m%d_%H%M%SZ) | |
| YYMMDD_hhmmss (with local TZ) | date +%Y%m%d_%H%M%S%Z | $(date +%Y%m%d_%H%M%S%Z) | |
| YYMMSShhmmss | date +%Y%m%d%H%M%S | $(date +%Y%m%d%H%M%S) | |
| YYMMSShhmmssnnnnnnnnn | date +%Y%m%d%H%M%S%N | $(date +%Y%m%d%H%M%S%N) | |
| Seconds since UNIX epoch: | date +%s | $(date +%s) | |
| Nanoseconds only: | date +%N | $(date +%N) | |
| Nanoseconds since UNIX epoch: | date +%s%N | $(date +%s%N) | |
| ISO8601 UTC timestamp | date --utc +%FT%TZ | $(date --utc +%FT%TZ) | |
| ISO8601 Local TZ timestamp | date +%FT%T%Z | $(date +%FT%T%Z) | |
| ISO8601 UTC timestamp + ms | date --utc +%FT%T.%3NZ | $(date --utc +%FT%T.%3NZ) | |
| EOD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment