Mono Chinese Forum address: http://www.sinoprise.cn/showtopic-242.aspx
In JavaScript, the time is recorded in milliseconds, and the start time is. This is UTC (GMT. In China, it should be, because China is in the GMT + 8 hours ). The C # Time is recorded in units of ticks. the literal translation is the CPU time "tick", which is a unit smaller than milliseconds. In the conversion between the two, pay attention to the conversion of the start time and the time zone.CodeHowever, to convert the time from C # To javascript:
Reference:
Public long millitimestamp (datetime thedate)
{
Datetime d1 = new datetime (1970, 1, 1 );
Datetime D2 = thedate. touniversaltime ();
Timespan Ts = new timespan (d2.ticks-d1.ticks );
Return (long) Ts. totalmilliseconds;
}
Note:
Timespan Ts = new timespan (d2.ticks-d1.ticks );
Cannot be written:
Timespan Ts = d2-d1.ticks;
If the second method is used, the time passed to JavaScript will be added with 8 hours on the basis of the GMT +. My test time is and it will be after being printed in JavaScript.
In the first method, the DOTNET framework automatically converts the time zone.
I have time to study it in detail.