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