UNIX timestamps are not used in. Net-based applications. UNIX timestamps are used when. Net Applications interact with other applications (such as PHP and Java. Once used in a project, when a user submits data through a web app and shares it with an Android app, the data can be real and valid only when the time interval is within one minute. Otherwise, the data will not be processed. In the development of Asp.net, the object is often serialized into JSON data. JS is spliced into HTML, and the date object is serialized into the following format: {"Date ": "\/date (1349839763373) \/"}. js cannot recognize it yet. In this case, consider converting a date to a Unix timestamp.
The conversion between the date and Unix timestamp in C # is as follows:
/// <Summary> /// convert a date to a Unix timestamp /// </Summary> /// <Param name = "datetime"> </param> /// <returns> </returns> Public static long datetimetounixtimestamp (datetime) {var start = new datetime (1970, 1, 1, 0, 0, 0, datetime. kind); Return convert. toint64 (datetime-Start ). totalseconds );} /// <summary> // convert UNIX timestamp 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 );}
Speaking of this date (January 1, 1970), the computing and display of the time of computers and some electronic devices are based on time (that is, 00:00:00 on January 1, Greenwich Mean Time. the offset of the, gregali calendar) is standard, and some people play to the British Greenwich Observatory as "the place of time ".
Appendix:
1. timestamp conversion for each language: http://www.epochconverter.com/
2. UNIX time introduction: http://en.wikipedia.org/wiki/Unix_time