2013-01-10 13 views
6

私はこの分野移入するには、このタスクがあります。秒のタイムスタンプを作成する方法

x_fp_timestamp is the timestamp created when the form is generated. It is equal to the number of seconds since January 1, 1970 in UTC (Coordinated Universal Time).

だから私はC#で何が

long ts = DateTime.Now.Ticks/TimeSpan.TicksPerSecond; 

である。しかし、その場合には、私はこのエラーを取得していた:

  • x_fp_timestamp : x_fp_timestamp invalid. Not within 15 minutes of present time: Thu Jan 10 21:30:25 GMT 2013. Expected 1357853425 plus/minus 900, but received 63493442997.

私の質問は、現在のタイムスタンプを秒単位で生成する方法です。

+0

可能な重複:http://stackoverflow.com/questions/3354893/how-can-i-convert-a-datetime-to-the-number-of-seconds-since代わりにこのような何かを試してみてください-1970 –

+1

ここには良いリンクがたくさんあります。Peretz [DateTimeオブジェクトをUnixタイムスタンプ番号に変換します](http://www.java2s.com/Code/CSharp/Date-Time /ConvertsaDateTimeobjectintoaunixtimestampnumber.htm) – MethodMan

答えて

16

DateTime.Now.Ticksdoes not start at 1970;

(DateTime.Now.ToUniversalTime() - new DateTime (1970, 1, 1)).TotalSeconds 
+1

+ Lagavulin man 1瓶! –

関連する問題