Get the current timestamp in seconds
Convert a date-time to whole Unix seconds.
function unixSeconds(now) { return Math.floor(Date.parse(now) / 1000); }
Input & expected output
Input
"2026-10-28T14:00:00Z"Expected output
1793196000The edge case
Input
"1970-01-01T00:00:00.999Z"Expected output
0Know the limits
- now is an input so the result is testable; pass new Date().toISOString(), or use Math.floor(Date.now() / 1000).
- Oveyon’s x-oveyon-timestamp webhook header is in these units: compare it with the current value to reject stale deliveries, as the signature lab shows.
The function above is the implementation used by the lab. The lab validates JSON types and caps size before execution; include equivalent validation when accepting untrusted input in your application.
Source & maintenance
Based on Get the current timestamp in seconds from the original 1loc collection by Nguyen Huu Phuoc. Copyright (c) 2020 phuoc-ng. MIT licensed.
Takes the current time as an input so the result is reproducible. Original MDX retained as inert source evidence.
Maintained by Oveyon. Source commit: 14b481cf60df. Read the license.
Keep exploring
- Compare two dates — Compare validated ISO calendar dates in UTC and return -1, 0 or 1.
- Add AM PM suffix to an hour — Turn an hour from 0 to 23 into a 12-hour label with am or pm.
- Calculate the number of days between two dates — Count whole calendar days between two YYYY-MM-DD dates.