How to create a timestamp in seconds

I have this task to fill in this field:

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

So what am I doing in C #,

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

But in this case, I get this error:

  • x_fp_timestamp: x_fp_timestamp is not valid. Not for 15 minutes now: Thu January 10, 21:30:25 GMT 2013. Expected 1357853425 plus / minus 900, but received 63493442997.

So my question is how to generate the current timestamp in seconds?

+6
source share
1 answer

DateTime.Now.Ticks did not start in 1970 ; try something like this:

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

All Articles