Linux Views 4

The Linux date command

The Linux date command image 1

date reports or sets the system date and time. If you use it with no options, it shows the current time and date

If you specify a format, the time is shown according to that format.

date [option] [+format]

Category Description 
 Option  -d  Displays the given date.
 -f  Displays a date for each line in the given file.
 -r  Displays the date the given file was last modified.
 -s  Sets the time to the given value.
 Format  %d  Day of the month (01–31)
 %j  Day of the year (01–365)
 %k  Hour in 24-hour time (0–23)
 %l  Hour in 12-hour time (0–12)
 %m  Month of the year (1–12)
 %n  Insert a new line
 %p  AM /  PM

Command examples

Print how many days of this year have passed

Print in the given format (month-day-year)

The Linux date command image 2

Reactions

Comments 0

A nickname and a password are required. The same password edits or deletes the comment later. Comments appear after a review.

Comments appear after a review. The password is used again to edit or delete.