C # Get the time difference (a few days ago, a few hours ago, a few minutes ago, a few seconds ago)

Source: Internet
Author: User

1         #regionGet time difference string GetTime (bsonstring GetTime)2         /// <summary>3         ///Get time difference4         /// </summary>5         /// <param name= "GetTime" >Database Time</param>6         /// <returns>Time Difference</returns>7         Private stringGetTime (bsonstring GetTime)8         {9             vartime1 = DateTime.ParseExact (convert.tostring (GetTime),"YYYY-MM-DD HH:mm:ss",NULL);Ten             varTime = DateTime.Now-time1; One  A             if(Time. TotalHours > -) -             { -                 returnMath.floor (time. Totaldays) +"days ago"; the             } -             if(Time. TotalHours >1) -             { -                 returnMath.floor (time. TotalHours) +"hours ago"; +             } -             if(Time. Totalminutes >1) +             { A                 returnMath.floor (time. Totalminutes) +"minutes ago"; at             } -             returnMath.floor (time. TotalSeconds) +"seconds ago"; -         } -         #endregion

C # Get the time difference (a few days ago, a few hours ago, a few minutes ago, a few seconds ago)

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.