Reproduced in: http://blog.csdn.net/tyxkzzf/article/details/49132237
Before programming, know how big Timespan.ticks is in C #:
Tick the smallest time unit scale, equivalent to 100 nanometers (1 nai seconds equals one-zero seconds). The scale can be positive and negative.
Here's a C # example to calculate the time difference for the next two dates.
DateTime dt = new DateTime (1970, 1, 1);
TimeSpan d =datetime.parse ("2011/12/24 9:41:40")-DT;
Long Seconddiff =d.ticks/10000000;
The calculated D.ticks is in nanoseconds and must be divided into seconds to divide by 1000000000; the result is 1324719700;
That, in turn, is known to date, the date of the N-second difference between this date, is the number of seconds of the date has been calculated, and then the difference between the number of seconds to add.
What is the date of January 1, 1970 with a difference of 1324719700 seconds?
DateTime dt = new DateTime (1970, 1, 1);
DateTime Ts=dt. AddSeconds (1324719700);
MessageBox.Show (TS. ToString ("Yyyy/mm/dd hh:mm:ss"));
Get results for 2011/12/24 9:41:40
C # Datetime.ticks converts time into seconds and GMT