Date

From Wiki
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
date '+%F'  # 2019-04-11
<pre>

== Setting the date ==
Example: 
<pre>
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)