Date time in ISO8601 format In Linux – Linux Tips And Tricks
Learn how to get date and time in ISO8601 format in Linux.
Thse are the commands that are demonstrated in the video.
Full date format (same as %Y-%m-%d)
date +%F
Time (same as %H:%M:%S)
date +%T
Date and Time
date +%FT%TZ
OUTPUT
2022-12-12T15:26:28Z
Just get zone
date +%z
OUTPUT
+0000
Format zone with colon
date +%z | sed ‘s/.{2}$/:&/’
OUTPUT
+00:00
FINAL
dateZone=`date +%z | sed ‘s/.{2}$/:&/’`; echo `date +%FT%TZ` »$dateZone »
OUTPUT
2022-12-12T18:57:13Z+00:00
#linux #ubuntu #redhat #bash
Views : 153
linux