Datetime

Datetime #

Use the date command in linux to get datetime. The -I flag gives a ISO-8601 formatted date string. To also print time, append hours, minutes, seconds or ns after the flag.

date -Iminutes

This command is also useful for formatted strings. The format string starts with the + symbol.

date "+%H:%M:%S   %d/%m/%y"
date "+%V"
date "+%W"

Outputs:

11:38:42   07/10/22
40
40
  • Both the %W and %V flag gives the week number of the year, with Monday as the first day of week. However %V is the ISO week number, ranging from 01..53. %W ranges from 00..53. I did not see the difference yet.