Subtract two times

Source: Internet
Author: User


<1>

Using system;using system.collections.generic;using system.linq;using system.text;namespace Test{class Program {             static void Main (string[] args) {DateTime T1 = datetime.parse ("2007-01-01");            DateTime t2 = datetime.parse ("2006-01-01");  system.timespan t3 = t1-t2; Subtract two times. The default is to get the number of days between two times: 365.00:00:00 double getDay = t3. Totaldays; Convert this number of days to days, the return value is double type (actually do not have to convert, because T3 default is the number of days) get: Double getHours = t3. TotalHours; Convert this number of days to hours, and the return value is double of type getminute = T3. Totalminutes; Convert this number of days to the component clock, and the return value is double of type getseconds = T3. TotalSeconds; Converts this number of days to seconds, and the return value is double of type getmillisecond = T3. TotalMilliseconds;  Converts this number of days to milliseconds, and the return value is a double of type Console.WriteLine (T3); Output: 365.00:00:00 Console.WriteLine (GetDay); Output: 365 Console.WriteLine (getHours); Output: 8760 Console.WriteLine (Getminute); Output: 525600 Console.WriteLine (getseconds); Output: 31536000 Console.WriteLine (Getmillisecond);        Output: 31536000000 console.readkey ();   }


Subtract two times

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.