Difference between revisions of "Date (command)"

From wikieduonline
Jump to navigation Jump to search
Tags: Mobile web edit, Mobile edit
Tags: Mobile web edit, Mobile edit
Line 6: Line 6:
 
  $date -I or date --iso-8601
 
  $date -I or date --iso-8601
 
  2020-01-28
 
  2020-01-28
 +
 +
date --iso-8601=seconds
 +
2014-03-19T16:51:16-0600
  
 
  $date --[[rfc-3339]]=date
 
  $date --[[rfc-3339]]=date

Revision as of 04:31, 7 July 2020

date[1] command allows to print or set the system date and time.


Basic Examples

$date -I or date --iso-8601
2020-01-28
date --iso-8601=seconds
2014-03-19T16:51:16-0600
$date --rfc-3339=date
2020-01-28
$ date -d now
Wed Aug 18 16:47:31 EDT 2019

$ date -d today
Wed Aug 18 16:47:32 EDT 2019
$ date -d yesterday
Tue Aug 17 16:47:33 EDT 2019

$ date -d tomorrow
Thu Aug 19 16:46:34 EDT 2019

$ date -d sunday
Sun Aug 22 00:00:00 EDT 2019

$ date -d last-sunday
Sun Aug 15 00:00:00 EDT 2019
Other valid date time strings include: last-week, next-week, last-month, next-month, last-year, and next-year.

$ date +%b
Aug 

$date "+%b %d"
Aug 28

$ date +%B
August

$date "+%Y-%m-%d"
2020-10-11

$date "+%F_%H:%M-%Z"
2020-11-22_12:18-UTC

$date --rfc-3339=date
2020-01-28

MacOS:
$ date +%F_-%T
2020-08-03_-09:14:54

Activities

  1. Read date man page: http://man7.org/linux/man-pages/man1/date.1.html


See also

  • http://man7.org/linux/man-pages/man1/date.1.html
  • Advertising: