Date Command

Date command is used to show the date in the UNIX OS.

Syntax: date

: date “+ format”

Date “+%m/%d/%y”

04/24/16

Date “+%Y%m%d”

20160424

Date ‘+ Date: %d%m%Y%nTime : %H %M %S’

Date: 24/04/2016

Time: 14:47:22

Date ‘+%d-%m-%Y %H-%M-%S’

24-04-2016 15-04-20

To change date and time ,use “-s”

Date -s “04/24/2016 15:05:23”

To display only time part

Date ‘ +%H-%M-%S’



Other Formats

date +%a  — Shows Weekday name in short [Mon, Tue ..]

date +%A  — Shows Weekday name in full [Monday, Tuesday ..]

date +%b  — Shows Month name in short [Jan,Feb..]

date +%B  — Shows Month name in full [January, February..]

date +%d  — Shows Day of month[01, 02 ..]

date +%D  — Shows Current Date; in MM/DD/YY

date +%F  — Shows Date; in YYYY-MM-DD

date +%H  — Shows hour in [00..23] format

date +%I  — Shows hour [01..12] format

date +%j  — Shows day of year [001..366]

date +%m  — Shows month [01..12]

date +%M  — Shows minute [00..59]

date +%S  — Shows second [00..60]

date +%T  — Shows time in HH:MM:SS

date +%U  — Shows week number of year, with Sunday as first day of week [00..53]

date +%Z  — alphabetic time zone abbreviation (e.g., EDT)