📝 Edit page
➕ Add page
Output format
Examples here use the current time.
See the GNU Date and BSD Date cheatsheets for more info on formats.
Default format
Get a standardized ISO date by default.
$ date
Mon 22 Feb 2021 17:58:01 SAST
Store it.
$ CURRENT_TIME=$(date)
$ echo $CURRENT_TIME
Mon 22 Feb 2021 17:58:01 SAST
Custom format
- Full date.
$ date '+%Y/%m/%d' 2021/02/22
- Year only.
$ date '+%Y' 2021
- Time only.
$ date '+%H:%M:%S' 18:34:49
- Date and time.
$ date '+%Y-%m-%dT%H:%M:%SZ'
And to store it:
$ DATE=$(date '+%Y-%m-%dT%H:%M:%SZ')