Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Day/Date countdown to an event 3

Status
Not open for further replies.

armylogman

Technical User
Feb 16, 2005
34
0
0
US
I am trying to do a date countdown for each day that passes between 19 Nov to 27 Nov I want to display a message each day counting down from 8 days out down to the last day of 27 Nov here is what i am doing now sure there is a better way

moda1=`date '+%m%d'`

if [ $moda1 -eq 1119 ]
echo "The exercise is 8 days away please be prepared to start on 27 Nov......"
read
echo " PRESS any key to continue....."
read
clear
else
break
fi
if [ $moda1 -eq 1120 ]
echo "The exercise is 7 days away please be prepared to start on 27 Nov......"
read
echo " PRESS any key to continue....."
read
clear
else
break
fi




 
What about this ?
Code:
moda1=`date '+%m%d'`
if [ $moda1 -ge 1119 -a $moda1 -lt 1127 ]; then
  da1=`date '+%d'`
  ndays=`expr 27 - $da1`
  echo "The exercise is $ndays days away please be prepared to start on 27 Nov......"
  read
  echo " PRESS any key to continue....."
  read
  clear
fi

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi

Code:
[navy]nov27[/navy][teal]=[/teal][green][i]'1353967200'[/i][/green]
[navy]now[/navy][teal]=[/teal][green][i]"$( date '+%s' )"[/i][/green]

echo [green][i]"The exercise is $(( (nov27-now)/60/60/24 )) days away please be prepared to start on 27 Nov......"[/i][/green]
Tested with Bash, MKsh and Dash.

Feherke.
[link feherke.github.com/][/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top