-
timer!
Hi there.
I am making a simple countdown app. i have almost done it but instead of the mins and seconds going down, it goes up. how can i make it go down?
Code:
DateTime currentTime = new DateTime();
string hourNows = DateTime.Now.ToString().Substring(11, 2);
string minNows = DateTime.Now.ToString().Substring(14, 2);
string secNows = DateTime.Now.ToString().Substring(17, 2);
int hourNow = Int32.Parse(hourNows);
int minNow = Int32.Parse(minNows);
int secNow = Int32.Parse(secNows);
int theHour = Int32.Parse(tc.EventTimeInput.Text.Substring(0, 2));
int theMin = Int32.Parse(tc.EventTimeInput.Text.Substring(3, 2));
int theSec = Int32.Parse(tc.EventTimeInput.Text.Substring(6, 2));
int theSecCalc = secNow - theSec;
int theHourCalc = theHour - hourNow;
int theMinCalc = minNow - theMin;
if(theHourCalc == 0 || theHourCalc < 0)
{
theHour = 0;
hourNow = 0;
theHourCalc = 0;
}
else if(theMinCalc == 0 || theMinCalc < 0)
{
theMin = 0;
minNow = 0;
theMinCalc = 0;
}
else if(theSecCalc == 0 || theSecCalc < 0)
{
theSec = 0;
secNow = 0;
theSecCalc = 0;
}
TimeDisplay.Text = theHourCalc + ":" + theMinCalc + ":" + theSecCalc;