Date Command in Linux
Exploring Date Command in Linux

Date Command in Linux

The date command in linux is used to display the current time in the given format, or set the system time.

Besides checking the date, you can do couple of more things using the date command like identifying a week or day from a date, calculating the time from epoch to a specified time, and a few more variations.

Options available in date command :-

1. -d , — date = “string” : Display the given date string.

No alt text provided for this image
No alt text provided for this image

2. Format options :

  • date +”Year: %Y, Month: %m, Day: %d” : Here, the %Y character is replaced with the current year, %m with month, and %d with the day of the month:

No alt text provided for this image

  • date “+DATE: %D%nTIME: %T”

No alt text provided for this image

  • date +”Week number: %V Year: %y”

No alt text provided for this image

These are the most common formatting characters for the date command:

  • %D – Display date as mm/dd/yy
  • %Y – Year (e.g., 2020)
  • %m – Month (01-12)
  • %B – Long month name (e.g., November)
  • %b – Short month name (e.g., Nov)
  • %d – Day of month (e.g., 01)
  • %j – Day of year (001-366)
  • %u – Day of week (1-7)
  • %A – Full weekday name (e.g., Friday)
  • %a – Short weekday name (e.g., Fri)
  • %H – Hour (00-23)
  • %I – Hour (01-12)
  • %M – Minute (00-59)
  • %S – Second (00-60)

3. — set option : Set or Change Date in Linux.

No alt text provided for this image

4. Display the past and future dates : Use the --date option to display past and future dates in Linux.

No alt text provided for this image

5. -r : Print the last modification time of a file.

No alt text provided for this image

. . .

Thank-you!

Hope you find this blog post helpful. Share it with your friends!


To view or add a comment, sign in

More articles by Atishay Jain

  • Funny Commands in Linux

    sl (Steam Locomotive): You might be aware of the command ‘ls’ in linux. It is used to view the contents of a folder.

  • ESPEAK-NG COMMAND, LINUX

    What is espeak-ng? The eSpeak NG is a compact open-source software text-to-speech synthesizer for Linux, Windows…

  • Zenity Command-- Linux

    What is Zenity ? Zenity is a program that will display GTK+ dialogs, and return the user's input. This allows you to…

Others also viewed

Explore content categories