- Fri 04 March 2016
- misc
Increasing amounts of stuff these days uses ISO 8601 date format.
Of course, date(1) isn't one of them, at least without a nice clean single flag on the command line.
If you need "now" in ISO 8601 format in a shell script or staring at you from a terminal, what do you do?
On SmartOS, node.js is already there by default, which makes it pretty easy to springboard off that installation.
Incantation is:
node -e 'console.log(new Date().toISOString());'
Alternate plain-unix-only-only method, courtesy of the README.md for mountain-gorilla:
- TIMESTAMP is an ISO timestamp like "20110729T063329Z". Use:
TIMESTAMP=$(shell TZ=UTC date "+%Y%m%dT%H%M%SZ") # Makefile TIMESTAMP=$(TZ=UTC date "+%Y%m%dT%H%M%SZ") # Bash script