Get the current timestamp in seconds

Convert a date-time to whole Unix seconds.

JavaScript Version 1.0.0 · MIT · .md

get-the-current-timestamp-in-seconds.js
function unixSeconds(now) { return Math.floor(Date.parse(now) / 1000); }

Input & expected output

Input

"2026-10-28T14:00:00Z"

Expected output

1793196000

The edge case

Input

"1970-01-01T00:00:00.999Z"

Expected output

0

Know 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.

Local fixture scope · Node.js 22.23.2 · reviewed October 28, 2026. No external service is required.

Keep exploring

Type two or more characters. Try “duplicate”, “webhook” or “retry”.