JS time stamp into C # time, and then the C # time stamp into JS time
The time stamp in JS
Copy Code code as follows:
var dt = new Date (). GetTime ();//Time stamp
C # time stamp turn time
Copy Code code as follows:
DateTime Dtstart = TimeZone.CurrentTimeZone.ToLocalTime (New DateTime (1970, 1, 1));
Long ltime = long. Parse (dt + "0000"); Description, the time format is 13 digits after 4 "0", if the time format of 10 digits then add 7 "0", as for why I am not too clear, but also in the same way that people write code conversion
TimeSpan Tonow = new TimeSpan (ltime);
DateTime Dtresult = Dtstart.add (Tonow); Get the time after conversion
-------------------------------------------------------------------------------
C # time-turn timestamp
Copy Code code as follows:
System. DateTime starttime = TimeZone.CurrentTimeZone.ToLocalTime (new System. DateTime (1970, 1, 1, 0, 0, 0, 0));
Intresult = (time-starttime). TotalMilliseconds;
DateTime dtresult//Fetch Time
Long T = (dtresult.ticks-starttime.ticks)/10000;//except 10000 adjusts to 13 bits
Js
Copy Code code as follows:
var d = new Date (data); Time Stamp Turn time
Alert (FormatDate (d));
Format time
function FormatDate (now) {
var year=now.getfullyear ();
var month=now.getmonth () +1;
var date=now.getdate ();
var hour=now.gethours ();
var minute=now.getminutes ();
var second=now.getseconds ();
return year+ "-" +month+ "-" +date+ "" +hour+ ":" +minute+ ":" +second; "
}
The code is super simple, but it is very practical, small partners to refer to the