The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 07-14-2008
Ikon's Avatar
Ikon Ikon is offline Forum Advisor  
Registered User
  
 

Join Date: Jul 2008
Location: Phoenix, Arizona
Posts: 669
IM not gonna write the whole script for you but this should get you started:

#Current Day of Month
d=`date +%d`

#current Month
m=`date +%m`

#current Year on 4 digit format
y=`date +%Y`


TARGET=$(date -u -d '2008-07-13 00:00:00' '+%F %T.%N %Z')
CURRENT=$(date -u -d'$Y-$m-$d 00:00:00' '+%F %T.%N %Z')

#function to get the diff of 2 dates
diff () {
printf '%s' $(( $(date -u -d"$TARGET" +%s) -
$(date -u -d"$CURRENT" +%s)))
# %d = day of month.
}

# $DAYS will equal the diff of $CURRENT and $TARGET, Below numbers are 60 = Minutes per hour, 24 = Hours perday
DAYS=$(( $(diff) / 60 / 60 / 24 ))