You can use date -I[FMT] or –iso-8601[=FMT] option to output date/time in ISO 8601 format. FMT=’date’ for date only (the default), ‘hours’, ‘minutes’, ‘seconds’, or ‘ns’ for date and time to the indicated precision.
date -I[TIMESPEC] or –iso-8601[=TIMESPEC] option example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
## default date ## returns Mon, May 25, 2020 8:49:45 AM ## date -I[TIMESPEC] or --iso-8601[=TIMESPEC] option ## auto - Print just the date. This is the default if TIMESPEC is omitted. date -I ## returns 2020-05-25 ## hours - Append the hour of the day to the date. date -Ihours ## returns 2020-05-25T08+05:30 ## minutes - Append the hours and minutes. date -Iminutes ## returns 2020-05-25T08:53+05:30 ## seconds - Append the hours, minutes and seconds. date -Iseconds ## returns 2020-05-25T08:54:23+05:30 ## ns - Append the hours, minutes, seconds and nanoseconds. date -Ins ## returns 2020-05-25T08:54:59,549507700+05:30 |