C # two time subtraction

Source: Internet
Author: User

Original address: http://www.jb51.net/article/60177.htm
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text; namespaceTest {classProgram {Static voidMain (string[] args) {DateTime T1= DateTime.Parse ("2007-01-01"); DateTime T2= DateTime.Parse ("2006-01-01"); System.TimeSpan T3= T1-t2;//two time subtraction. By default, the number of days between two times is obtained: 365.00:00:00             DoubleGetDay = 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:             DoublegetHours = T3. TotalHours;//converts this number of days to hours, and the return value is a double of type             DoubleGetminute = T3. Totalminutes;//convert this number of days to the component clock, the return value is double type             Doublegetseconds = T3. TotalSeconds;//converts this number of days to seconds, and the return value is of type double.             DoubleGetmillisecond = T3. TotalMilliseconds;////Converts this number of days to milliseconds, and the return value is of type doubleConsole.WriteLine (T3); //Output: 365.00:00:00Console.WriteLine (GetDay);//output: 365Console.WriteLine (getHours);//Output: 8760Console.WriteLine (Getminute);//Output: 525600Console.WriteLine (getseconds);//Output: 31536000Console.WriteLine (Getmillisecond);//Output: 31536000000Console.readkey (); }     }}

C # two time subtraction

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.