Date

From Wiki
Revision as of 18:28, 4 February 2011 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

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)