How To Display The Date And Time Using Linux Command Line

images (6)
images (6)
You could possibly have guessed the command to show the date and time using the linux command line. It's far pretty honestly

In this manual, i will display you how to print the date and time using the linux command line in diverse formats.

The way to display the date and time

You could possibly have guessed the command to show the date and time using the linux command line. It’s far pretty honestly this:


By way of default the output can be something like this:

Wed apr 20 19:19:21 bst 2016

You may get the date to display any or all of the following factors:

  • %a – abbreviated day name (i.E. Mon, tue, wed)
  • %A – full day call (i.E. Monday, tuesday, wednesday)
  • %b or %h – abbreviated month call (i.E. Jan, feb, mar)
  • %B – full month name (january, february, march)
  • %c – locales date and time (full date and time)
  • %C – short yr (i.E 14, 15, 16)
  • %d – day of month (i.E. 01, 02, 03)
  • %D – same as m/d/y (i.E. 04/20/sixteen)
  • %e – day of month padded (i.E. ‘ 1’, ‘ 2’)
  • %F – full date, same as yyyy-mm-dd
  • %H – hour (00, 01, 02, 21, 22, 23)
  • %I – hour (1,2,3,10,11,12)
  • %j – day of yr (i.E. 243)
  • %k – hour padded (i.E. ‘1’ will become ‘ 1’)
  • %l – hour padded (12 hour clock)
  • %m – month variety (1,2,3)
  • %M – minute (1,2,three,57,fifty eight,fifty nine)
  • %n – new line
  • %N – nanoseconds
  • %P – am or pm
  • %p – like %p but lowercase (paradoxically)
  • %r – locales 12 hour clock time
  • %R – 24 hour model of hour and minute
  • %s – seconds due to the fact 1970-01-01 00:00:00
  • %S – 2nd (01,02,03, fifty seven, 58, fifty nine)
  • %t – a tab
  • %T – time equal as %h:%m:%s
  • %u – day of week (1 is monday, 2 is tuesday etc)
  • %U – week number of year (assuming sunday as first day of the week)
  • %v – iso week variety with monday because the first day of the week
  • %w – day of week (zero is sunday)
  • %W – week quantity of the year with monday because the first day of the week
  • %x – locales date illustration (12/31/2015)
  • %X – locales time representation (14:44:forty four)
  • %y – closing digits of yr
  • %Y – 12 months
  • %z – numeric time area (i.E. -0400)
  • %:z – numeric time quarter as follows (i.E. -04:00)
  • %::z – numeric time area as follows (i.E. -04:00:00)
  • %Z – alphabetic time area abbreviation (gmt)
  • – – a unmarried hyphen prevents 0 padding
  • _ – a unmarried underscore pads with areas
  • 0 – pads with zeroes
  • ^ – use uppercase if viable
  • # – use contrary case if feasible
READ  How to Find Files and Folders on Linux

That could be a huge wide variety of options and i suspect the date command is the one most of the people attempt to add something to once they first want to make a contribution to linux and collect their first application.

Essentially in case you want to show just the time you can use the following:

Date +%t

This may output 19:forty five:00. (i.E. Hours, minutes then seconds)

You may additionally attain the above via the usage of the following:

Date +%h:%m:%s

You could connect the date as properly using the above command:

Date +%d/%m/%yp.Ctp.Ch:%m:%s

Essentially you can use any combination of the above switches after the plus image to output the date as you so wish. If you want to feature spaces you can use prices around the date.

Date +'%d/%m/%y %h:%m:%s'

How to show the utc date

You can view the utc date for your computer using the subsequent command:

Date -u

If you are within the uk you will note that rather than displaying “18:fifty eight:20” because the time it’ll display “17:fifty eight:20” because the time.

How to expose the rfc date

You could view the rfc date for your pc using the following command:

Date -r

This shows the date inside the following format:

Wed, 20 apr 2016 19:fifty six:52 +0100

That is useful as it shows which you are an hour beforehand gmt.

Some beneficial date instructions

Do you need to realize the date next monday? Do that out:

Date -d "next monday"

At the point of writing this returns “mon 25 apr 00:00:00 bst 2016”

READ  Delete / Remove a Directory using Linux Command

The -d essentially prints a date inside the future.

Using the same command you could find out which day of the week your birthday or christmas is on.

Date -d 12/25/2016

The result is sun dec 25.


It’s far worth sorting out the manual page for the date command the use of the subsequent command:

man date

About the author

Venkatesan Prabu

Venkatesan Prabu

Wikitechy Founder, Author, International Speaker, and Job Consultant. My role as the CEO of Wikitechy, I help businesses build their next generation digital platforms and help with their product innovation and growth strategy. I'm a frequent speaker at tech conferences and events.

Add Comment

Click here to post a comment