In. NET-based applications, UNIX timestamps are not used and UNIX timestamps are used when the. NET app interacts with other applications (eg:php, Java). Once used in the project, users submit data through the Web app and share to the Android app, if the time interval within a minute, the data can be true and effective, otherwise not processed. in ASP. NET development, it is often necessary to serialize the object into JSON data, JS stitching into HTML, the Date object will be serialized into the following form: {"date": "\/date (1349839763373) \"},js is not recognized, Consider converting the date to a Unix timestamp.
The following is the conversion of dates and Unix timestamps under C #:
<summary>///Date converted to UNIX timestamp///</summary>///<param name= "DateTime" ></param>///< Returns></returns>public Static Long Datetimetounixtimestamp (datetime datetime) { var start = new DateTime (1970, 1, 1, 0, 0, 0, datetime.kind); Return Convert.toint64 ((Datetime-start). totalseconds);} <summary>///Unix timestamp converted to date//</summary>///<param name= "Unixtimestamp" > Timestamp (seconds) </param>// /<returns></returns>public static datetime unixtimestamptodatetime (this datetime target, long timestamp) { var start = new DateTime (1970, 1, 1, 0, 0, 0, Target. Kind); return start. AddSeconds (timestamp);}
Next to this date (1970-1-1), the computer and some electronic equipment time calculation and display is based on the calendar element (that is, Greenwich Mean Time January 1, 1970 00:00:00.000, Gregorian calendar) offset of the standard, some people jokingly called the British Green Wedge Observatory is " The place where time began. "
C # Timestamp conversion (RPM)