I want to make a Windows Form Application which only shows a timer as:
xx days xx hours xx minutes xx seconds
You can use a timespan format string and a timer:
DateTime endTime = new DateTime(2013,01,01,0,0,0);
private void button1_Click(object sender, EventArgs e)
{
Timer t = new Timer();
t.Interval = 500;
t.Tick +=new EventHandler(t_Tick);
TimeSpan ts = endTime.Subtract(DateTime.Now);
label1.Text = ts.ToString("d' Days 'h' Hours 'm' Minutes 's' Seconds'");
t.Start();
}
void t_Tick(object sender, EventArgs e)
{
TimeSpan ts = endTime.Subtract(DateTime.Now);
label1.Text = ts.ToString("d' Days 'h' Hours 'm' Minutes 's' Seconds'");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With