Date & Time


Table of Contents

cmd:date 
Usage 
Advanced Usages 
Set 
DESCRIPTION 
day of week 
tomorrow 
Calculate next business day 
Calculate next business day 
Calculate next business day 
cript with date operation?? 
cript with date operation?? 
cript with date operation?? 

cmd:date 

Usage 

$ date -I
2005-08-04

$ date -Iseconds
2005-08-04T17:24:39-0400

$ date -Iseconds -u
2007-06-21T13:10:18+0000

$ date '+%H:%M:%S'
17:24:41

$ date '+%Y%m%d'
20020321

$ date '+%y%m%d'
020321

Advanced Usages 

# tomorrow
date --date=tomorrow

# yesterday
date --date='-1 day'

# last month
date --date='-1 month'

# next month
date --date='+1 month' '+%m %Y'

Set 

$ printf 'Set current time: date '; date '+%m%d%H%M'
Set current time: date 03281506

$ printf 'Set current time: date '; date '+%m%d%H%M%y'
Set current time: date 0101184403

% date 03181019
Mon Mar 18 10:19:00 CST 2002

$  date
Mon Mar 18 10:19:03 CST 2002

DESCRIPTION 

Display the current time in the given FORMAT, or set the system date.

%Y     year (1970...)
%y     last two digits of year (00..99)
%m     month (01..12)
%d     day of month (01..31)
%H     hour (00..23)
%I     hour (01..12)
%M     minute (00..59)
%S     second (00..60); the 60 is for a leap  second

day of week 

Every system should have gnu date:

$ date -d "Sun Jul 25 09:10:27 PDT 1999" '+%w %a %A'
0 Sun Sunday

Dan Mercer