How to Display the Date and Time Using Linux Command Line

Use format characters to display the date and time with precision

What to Know

  • Print the date and time in various formats using the Linux command date.
  • View the manual page for the date command using the command man date.

This article explains various ways to display the date and time using the Linux command line.

How to Display the Date and Time

linux date

To display the date, type:


By default the output will be something like this:

Wed Apr 20 19:19:21 BST 2018

Display the date using any or all of the following elements:

  • %a: abbreviated day name (i.e. mon, tue, wed)
  • %A: full day name (i.e. Monday, Tuesday, Wednesday)
  • %b or %h: abbreviated month name (i.e. jan, feb, mar)
  • %B: full month name (January, February, March)
  • %c: locales date and time (full date and time)
  • %C: century - displays the first two numbers of the year (i.e 19 for 1999 and 20 for 2020)
  • %d: day of month (i.e. 01, 02, 03)
  • %D: same as M/D/Y (i.e. 04/20/16)
  • %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 year (i.e. 243)
  • %k: hour padded (i.e. '1' becomes ' 1')
  • %l: hour padded (12 hour clock)
  • %m: month number (1,2,3)
  • %M: minute (1,2,3,57,58,59)
  • %n: new line
  • %N: nanoseconds
  • %p: AM or PM
  • %P: like %p but lowercase (ironically) 
  • %r: locales 12 hour clock time
  • %R: 24 hour version of hour and minute
  • %s: seconds since 1970-01-01 00:00:00
  • %S: second (01,02,03, 57, 58, 59)
  • %t: a tab
  • %T: time same 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 number with Monday as the first day of the week
  • %w: day of week (0 is Sunday)
  • %W: week number of the year with Monday as the first day of the week
  • %x: locales date representation (12/31/2015)
  • %X: locales time representation (14:44:44)
  • %y: last two digits of year
  • %Y: year
  • %z: numeric time zone (i.e. -0400)
  • %:z: numeric time zone as follows (i.e. -04:00)
  • %::z: numeric time zone as follows (i.e. -04:00:00)
  • %Z: alphabetic time zone abbreviation (GMT) 
  • -: a single hyphen prevents zero padding
  • _: a single underscore pads with spaces
  • 0: pads with zeroes
  • ^: use uppercase if possible
  • #: use opposite case if possible

To display just the time use the following:

date +%T

Alternatively, use the following:

date +%H:%M:%S

Attach the date, as well, using the command:

date +%d/%m/%Y%t%H:%M:%S

Alternatively, use the follow (since %T is equivalent to %H:%M:%S):

date +$d/%m/%Y%t%T

The : and / characters are optional and can be whatever you want. For example:

date +%dc%mc%Y

outputs: 24c09c2020, if you wanted to use 'c' as a delimiter for some reason.

Use any combination of the above switches after the plus symbol to output the date as you so wish. If you want to add spaces you can use quotes around the date.

date +'%d/%m/%Y %H:%M:%S'

How to Show the UTC Date

View the UTC date for your computer using the following command:

date -u

If you are in the UK you will notice that instead of showing "18:58:20" as the time it will show "17:58:20" as the time.

How to Show the RFC Date

View the RFC date for your computer using the following command:

date --rfc-2822

This displays the date in the following format:

Wed, 20 Apr 2018 19:56:52 +0100

This flag is useful as it shows that you are an hour ahead of GMT.

Some Useful Date Commands

Do you want to know the date next Monday? Try this:

date -d "next Monday"

At the point of writing this returns "Mon 25 Apr 00:00:00 BST 2016"

The -d basically prints a date in the future or the past. So, you can use "next Monday" or "last Friday".

Using the same command you can find out which day of the week your birthday or Christmas falls upon.

date -d 12/25/2016

The result is Sun Dec 25. 


It is worth checking out the manual page for the date command using the following command:

man date
Was this page helpful?