C # time Stamp

Source: Internet
Author: User

First understand the time stamp

JavaScript Timestamp: GMT January 01, 1970 00:00 00 seconds (Beijing time January 01, 1970 08:00 00 seconds) up to now the total number of milliseconds.
Unix Timestamp: GMT January 01, 1970 00:00 00 seconds (Beijing time January 01, 1970 08:00 00 seconds) up to now the total number of seconds.
C # Timestamp: January 1, 01 0:0 0 seconds Start

//Unix timestamp to C # timestamp    /// <summary>    ///Unix Timestamp (1970 time) to C # time/// </summary>    /// <param name= "Unixtimestamp" ></param>    /// <returns></returns>     Public StaticDateTime Unixticks2cs (LongUnixtimestamp) {System.DateTime StartTime= TimeZone.CurrentTimeZone.ToLocalTime (NewSystem.DateTime (1970,1,1));//local time zoneDateTime dt =starttime.addseconds (Unixtimestamp); returnDT; }//time to find the difference between time stamps    /// <summary>    ///get Unix time stamp Difference value/// </summary>    /// <param name= "Endticks" >time stamp up to date</param>    /// <returns></returns>     Public StaticTimeSpan Gettimetickslerp (Longendticks) {datetime datetime=Unixticks2cs (endticks); returnDateTime-DateTime.Now; }

datetime d1 = new DateTime (2018, 5, 10);

datetime d1 = new DateTime (timestamp);

After 2 datetime subtracts, it is a TimeSpan type, and then you can. Days. Hour

C # time Stamp

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.