I have this task to populate this field:
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).
So what I do in C# is
long ts = DateTime.Now.Ticks / TimeSpan.TicksPerSecond;
But in that case I am getting this error:
- 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.
So my question is how to generate current timestamp in seconds?
To get the current date/time in seconds, use getTime()/1000.
If you'd like to calculate the difference between the timestamps in seconds, multiply the decimal difference in days by the number of seconds in a day, which equals 24 * 60 * 60 = 86400 , or the product of the number of hours in a day, the number of minutes in an hour, and the number of seconds in a minute.
Converting hours # There are 60 seconds in a minute, and 60 minutes in an hour. We'll divide our timestamp by 60 , and then by 60 again.
How to Use valueOf() to Generate Timestamps in JS. Just like the getTime() method, we have to attach the valueOf() method to a new Date() object in order to generate a Unix timestamp. The new Date() object, without getTime() or valueOf() , returns the information about your current time.
DateTime.Now.Ticks
does not start at 1970; try something like this instead:
(DateTime.Now.ToUniversalTime() - new DateTime (1970, 1, 1)).TotalSeconds
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With