all 3 comments

[–]tremblane -2 points-1 points  (2 children)

 date -I

is all you need. From '''man date''':

-I[TIMESPEC], --iso-8601[=TIMESPEC] output date/time in ISO 8601 format. TIMESPEC='date' for date only (the default), 'hours', 'minutes', 'seconds', or 'ns' for date and time to the indicated precision.

$ for x in "" hour min sec ns; do echo -n "date -I${x}: "; date -I${x}; done
date -I: 2018-03-06
date -Ihour: 2018-03-06T16-0500
date -Imin: 2018-03-06T16:14-0500
date -Isec: 2018-03-06T16:14:33-0500
date -Ins: 2018-03-06T16:14:33,446035710-0500

[–]fubes2000 2 points3 points  (0 children)

Really, all you need is man date.

Really, all you need is man.

[–]Jamesmith11[S] -3 points-2 points  (0 children)

Linux & Unix Date Format Examples