我有这个任务来填充这个字段:
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.
所以我的问题是如何以秒为单位生成当前时间戳?
最佳答案
DateTime.Now.Ticks
does not start at 1970 ;尝试这样的事情:
(DateTime.Now.ToUniversalTime() - new DateTime (1970, 1, 1)).TotalSeconds
关于c# - 如何以秒为单位创建时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14267984/