2013-01-10 8 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 [유닉스 타임 스탬프 (timestamp) 번호로 DateTime 객체를 변환합니다.] (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 남자 1 병 !!! –

관련 문제