Date: Difference between revisions

From Wiki
Jump to navigation Jump to search
No edit summary
 
Line 16: Line 16:
TIME:16:44:55
TIME:16:44:55
</pre>
</pre>
<pre>
date '+%F'  # 2019-04-11
<pre>


== Setting the date ==
== Setting the date ==

Revision as of 21:15, 11 April 2019

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)