date - Unix, Linux Command


Advertisements

Previous Page
Next Page  
 

NAME

date print or set the system date and time

SYNOPSIS

date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]

DESCRIPTION

Display the current time in the given FORMAT, or set the system date.

OPTIONS

TAG DESCRIPTION
-d, --date=STRING display time described by STRING, not 'now'.
-f, --file=DATEFILE like --date once for each line of DATEFILE

 

-r, --reference=FILE display the last modification time of FILE
-R, --rfc-2822 output date and time in RFC 2822 format. Example: Mon, 07 Aug 2006 12:34:56 -0600
--rfc-3339=TIMESPEC 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.
-s, --set=STRING set time described by STRING.

 

-u, --utc, --universal print or set Coordinated Universal Time
--help display this help and exit

 

--version output version information and exit

EXAMPLES

EXAMPLE-1:

To Print cureent system date and time:

$ date

output:
Sun Jan  8 21:38:15 IST 2017

EXAMPLE-2:

To print date of next Monday:

$ date --date="next mon"

output:
Mon Jan  9 00:00:00 IST 2017

EXAMPLE-3:

To display past date

$ date --date="1 day ago"
$ date --date="yesterday"

output:
Sat Jan  7 21:39:53 IST 2017

EXAMPLE-4:

To display future date

$ date --date="1 day"
$ date --date="tomorrow"
$ date --date="10 day"

output:
Wed Jan 18 21:41:26 IST 2017

EXAMPLE-5:

To set date:

$ date -s "Sun Dec 18 21:00:00 PDT 2016"

EXAMPLE-6:

To display Universal Time:

$ date -u

output:
Sun Jan  8 16:13:26 UTC 2017

EXAMPLE-7:

To display Weekday name:

$ date +%a 
$ date +%A 

output:
Sunday

EXAMPLE-8:

To display Month name:

$ date +%b
$ date +%B  

output:
January

EXAMPLE-9:

To display current day of month:

$ date +%d

output:
08

EXAMPLE-10:

To display Current Date in MM/DD/YY format:

$ date +%D

output:
01/08/17

EXAMPLE-11:

To display date in YYYY-MM-DD format:

$ date +%F

output:
2017-01-08

EXAMPLE-12:

To display time as HH:MM:SS, Note: Hours in 24 Format

$ date +%T

output:
21:47:05


Previous Page
Next Page