C # winform a simple project countdown timer

Source: Internet
Author: User

Namespace filebinding
{
Public partial class form1: Form
{
Public form1 ()
{
Initializecomponent ();
}

Private void form1_load (Object sender, eventargs E)
{
String STR = "2009-03-20"; // end date
Datetime dt2 = datetime. Now; // obtain the date of today
Datetime dt1 = convert. todatetime (STR); // convert the end date type to datetime

String datetime = NULL; // remaining time of the project

Timespan ST1 = new timespan (dt1.ticks );
Timespan st2 = new timespan (dt2.ticks );

Timespan Ts = st1.subtract (st2); // end date minus current date

String dateterm = ts. Days. tostring () + "day"
+ Ts. Hours. tostring () + "hour"
+ Ts. Minutes. tostring () + "Minute"
+ Ts. Seconds. tostring () + "seconds ";

Datetime = "before the end of the project" + dateterm;

Label2.text = datetime; // displayed in the label
// MessageBox. Show (dateterm );
}


}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.