Linux Date command

Linux date command allows you to display the current date and time.

Written under Linux commands


The root user can set the system time and date using the date command.


Linux date command allows you to display the current date and time.


The date command can be used without an option.


display time described by STRING, not `now'

like --date once for each line of DATEFILE

display the last modification time of FILE

output date and time in RFC 2822 format. Example: Mon, 07 Aug 2006 12:34:56 -0600

output date and time in RFC 3339 format. TIMESPEC=`date', `seconds', or `ns' for date and time to the indicated precision. Date and time components are separated by a single space: 2006-08-07 12:34:56-06:00

set time described by STRING

print or set Coordinated Universal Time

display this help and exit

output version information and exit

Usage and examples

$ date -d now
Mon Jun  4 21:15:02 EDT 2018

$ date -d today
Mon Jun  4 21:15:09 EDT 2018

$ date -d yesterday
Sun Jun  3 21:16:09 EDT 2018

$ date -d tomorrow
Tue Jun  5 21:16:17 EDT 2018

$ date -d sunday
Sun Jun 10 00:00:00 EDT 2018

$ date -d last-sunday
Sun Jun  3 00:00:00 EDT 2018

How to set Linux date via terminal?

$ date -s "3 Jun 2018 11:14:00"

Alternative you can use --set option:

$ date --set="2 OCT 2006 18:00:00"

Date version command output

$ date --version
date (GNU coreutils) 8.25
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by David MacKenzie.


Bash format date in shell script YYYY-MM-DD:

Get year-month-day from date

DATE=`date +%Y-%m-%d`

Get year-month-day hour:minute:second from date

DATE=`date '+%Y-%m-%d %H:%M:%S'`

Other available date formats can be viewed from the date man pages:

man date