Date

From Wiki
Revision as of 21:18, 11 April 2019 by Scott (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Displaying the date

To return the current date to look like 6/23/06:

date '+%m/%d/%y'

Another example:

date '+DATE: %m/%d/%y%nTIME:%H:%M:%S'

would list the time and date as below:

DATE: 02/08/01
TIME:16:44:55

iso format

date '+%F'  # 2019-04-11
# shorthand for #
date '+%Y-%m-%d'

Setting the date

Example:

date -s "11/20/2003 12:48:00"

On older Unix systems, this command works to set the date:

date MMDDHHMM[[CC]YY], e.g.
date 042716252006 (for 4:25pm, 4/27/2006)