How To Show Date And Time In Linux Terminal Using Date Command?

Wondering how to find Date And Time In Linux Terminal Using Date Command? Looking for a date and time Linux terminal command?

Linux is an open-source and community-developed operating system. It can be used for various computers, servers, mainframes, mobile devices, and embedded devices. It supports various computer platforms making it one of the widely supported operating systems.

The Linux Terminal commands is a utility of the Linux operating system. All tasks can be done by executing the Linux terminal commands. Linux commands are case-sensitive.

Why use Linux Terminal?

  • Absolutely Free
  • Can run in system with just 128MB RAM
  • Safe and Secure
  • Plenty of open source applications
  • Vibrant community

Date and Time Linux Terminal

The date command in Linux is used to display the system date and time. This command can be even used to set the date and time of the system. By default, to Date And Time In Linux Terminal Using Date Command in the time zone on which Unix/Linux OS is configured.

Syntax:

date [OPTION]… [+FORMAT]

date [-u|–utc|–universe] [MMDDhhmm[[CC]YY][.ss]]

This article will guide you on how to display the date and time in Linux Terminal using the date command.

The Default Date Command 

To run the default date Linux terminal command and to print the current date and time of your timezone. Use the “date” command. The default formatting might look a bit messy and look like it it’s a serious rearrange as the year is behind the timezone. But, if you wish to rearrange the format and want output in a few specific arrangements themselves, then don’t worry. 

Linux Terminal has more than 40 options to print output however you want.

Input: ~$ date

Output: Sun Jul 12 16:08:45 EDT 2021

ls displaying date and time Linux terminal 

To sort files concerning the last modified date and time. The ls displaying date and time Linux terminal will list all the files in a directory. To do this making use of the “-t” like shown below:

Input: ~$ ls -lt

Output: all the files in a dictionary will be listed

Sort ls Output by Date and Time
(Picture Credits: tecmint.com)

And if you wish to reverse the sorting files, then use the “-r” command like:

Input: ~$ls -ltr

Output: files will be listed in reverse order.

Sort ls Output Reverse by Date and Time
(Picture Credits: tecmint.com)

To Display Date And Time Of Local Time

To display date and time in Linux Terminal using the date command in the local format you will have to add “%c” after the date and the “%c” command must be followed by a “+” sign. The output will be printed in the normalized format with respect to your locale. Your locale will be set when you installed the Linux operating system. The locale covers things like currency symbols, paper sizes, timezone, etc.

Input: ~$ date +%c

Output: Sun 13 Jul 2021 04:09:03 PM EDT

Date Format String 

The date command allows passing several options to the “date” command, a sequence of options is called a format string. To display the name of the day, the day of the month, and the month name, use:

Input: ~$ date +%A%d%B   or   ~$ date +”%A %d %B”   or   ~$ date +”Today is: %A %d %B”

Output: Sunday13July or Sunday 13 July or Today is: Sunday 13 July

To Display the Date in Linux Terminal

You can format the output “date” in three ways:

  • %D: it prints the date in dd/mm/yy format
  • %F: it prints the date in yyyy-mm-dd format
  • %x: it prints the date in the format for your locale

Input: ~$ date +%D ~$ date +%F ~$ date +%x

Output: 04/07/21 2021-04-07 04/07/2021

To Display the Week in Linux Terminal
  • %U: it prints the week number of that particular year. (Sunday is the first day of the week).
  • %V: it prints the ISO week number of the year with Monday as the first day.
  • %W: it prints the week number of the year with Monday as the first day.

Input: ~$ date +%U ~$ date +%V ~$ date +%W

Output: 14        14         13

To Display the Month in Linux Terminal
  • %b or %h: it prints the name of the month. Like Jan, Feb, Mar, etc.
  • %B: it prints the full name of the month January, February, March, etc.
  • %m: it prints the number of the month, like 01, 02, 03, …., 12.

Input: ~$ date +%b ~$ date +%h ~$ date +%B ~$ date +%m

Output: Apr        Apr         April 04

To Display the Time in Linux Terminal
  • %T: it prints the time in HH: MM: SS format.
  • %R: it prints the hour and minutes as the HH: MM (with no seconds), it uses the 24-hr clock.
  • %r: it prints the time according to your locale, it uses the 12-hour format. It has an am or pm indicator.
  • %X: it prints the time according to the locale. It uses the 24-hour clock.

Input: ~$ date +%T ~$ date +%R ~$ date +%r ~$ date +%X

Output: 16:15:55            16:16 04:16:06 PM 04:16:06 PM

To Display the Hour in Linux Terminal
  • %H: it prints the hours in 00, 01, 02, …., 23.
  • %l: it prints the hour using the 12-hour clock, 00, 01, 02, …, 12.it will display output with leading zero if required.

Input: ~$ date +%H ~$ date +%I

Output: 16 04

Read also: 3 Alternate Sources To Download YouTube Videos For Free

To Display the Minutes in Linux Terminal

To display the minute on the Linux terminal screen give the “%M” command. It will display the outputs with a leading zero if required like 01, 02, 03, …. 59.

Input: ~$ date +%M

Output: 17

Read also: Is The Second Monitor Not Detected? Find Quick Solutions!

To Display the Seconds in Linux Terminal
  • %s: to display the number of seconds since 1970-01-01 00 : 00: 00, the start of the Unix
  • %S: to display the seconds with a leading zero if required. Such as 01, 02, 03, … 59.
  • %N: to print the Nanoseconds.

Input: ~$ date +%s ~$ date +%S ~$ date +%N 

Output: 1554668298 21 500161856

Read also: Apple’s ProRaw: The Photo Formatting App That Doesn’t Leave Behind Anything

To Display the Time zone Information in Linux Terminal

  • %z: it prints the time difference between your time zone and UTC
  • %:z: it prints the time difference between your time zone and UTC with a: between the hours, and minutes.
  • %::z: it prints the time difference between your time zone and UTC, with a: between hours, minutes, and seconds.
  • %Z: it prints the alphabetic time zone name.

That said, hope this article helped you with your code. There are more formats to display Date And Time In Linux Terminal Using Date Command.

Read More

Hey, we like you a lot and 

want to offer you some of the best content

Share your email for some exclusive insights