Skip to content

unixSeconds

const unixSeconds: RegExp = /^\d{10}$/;

RegExp matching a Unix timestamp in seconds: exactly 10 digits.

import { unixSeconds } from "@northguild/gmt";
unixSeconds.test("1710511800") // true
unixSeconds.test("0000000000") // true (epoch)
unixSeconds.test("9999999999") // true (2286-11-20T17:46:39Z)
unixSeconds.test("999999999") // false (unpadded; 2001-09-09T01:46:39Z)
unixSeconds.test("-1") // false (negative)
unixSeconds.test("17105118001") // false (11 digits)

regex/unix.ts