Numbers
Random Unix Timestamp Generator
A random Unix timestamp generator saves developers from manually calculating epoch offsets when they need realistic date values spread across a meaningful time window. Unix timestamps — integers counting seconds or milliseconds since January 1, 1970 — are the default date format in virtually every database, operating system, and API on the planet. Hardcoding a single date in test fixtures is brittle; a batch of randomized values catches edge cases like leap-year boundaries and month-end rollovers that static placeholders miss. Set a start and end year to match your production data window, pick seconds for PostgreSQL or Python and milliseconds for JavaScript and event-tracking platforms, then generate up to as many values as your dataset needs in one click.
How to use
- Choose your options above
- Click Generate
- Copy your result
Detailed instructions
- Set the Start Year and End Year to match the date window your test data should cover.
- Choose Seconds or Milliseconds from the Format dropdown to match your target language or database.
- Enter the number of timestamps you need in the Count field, then click Generate.
- Copy the output list and paste directly into your SQL script, JSON fixture, or CSV file.
Use Cases
- •Seeding a PostgreSQL table with randomized created_at values spread across 2000–2024 to test time-range index performance
- •Generating millisecond-format timestamps for Jest fixture files that feed a JavaScript date-filtering component
- •Populating a Postman collection's mock API responses with realistic event timestamps for a time-series endpoint
- •Creating CSV seed data for a Grafana or Metabase dashboard to verify that date-range charts render correctly
- •Producing randomized order timestamps for a k6 or Locust load-testing script simulating years of e-commerce history
Tips
- →Narrow the year range to 1–2 years when testing date-range filters; a 20-year spread rarely triggers the boundary bugs you're hunting.
- →Generate in seconds format first, then multiply by 1000 in your seed script — one conversion step is easier to audit than scattered format mismatches.
- →If your schema has a NOT NULL created_at and updated_at pair, generate two batches with the same range and pair them row-by-row, ensuring updated_at is always later.
- →For time-series stress tests, generate a large batch spanning only 30 days to create realistic data density that exposes query performance problems.
- →Cross-check a generated value at epochconverter.com before committing to a fixture file — one wrong format can silently corrupt an entire test suite.
- →When mocking IoT or sensor data, set the range to the past 90 days and use milliseconds so your timestamps align with modern event-streaming platforms like Kafka.
FAQ
seconds vs milliseconds unix timestamp — which one should I use?
Use milliseconds for JavaScript (Date.now(), new Date()), browser APIs, and event-tracking tools like Segment or Mixpanel. Use seconds for Python (time.time()), PostgreSQL's TO_TIMESTAMP(), MySQL's FROM_UNIXTIME(), and most Linux log parsers. The quickest check: a seconds timestamp is 10 digits; a milliseconds timestamp is 13 — if the digits don't match what your system expects, dates will be off by roughly 1,000 years.
how do I convert a unix timestamp back to a readable date in code?
In JavaScript: new Date(ts * 1000) for seconds or new Date(ts) for milliseconds. In Python: datetime.fromtimestamp(ts) for seconds or datetime.fromtimestamp(ts / 1000) for milliseconds. In SQL, use TO_TIMESTAMP(ts) in PostgreSQL or FROM_UNIXTIME(ts) in MySQL. All three approaches return a timezone-aware datetime, so make sure you account for the viewer's local offset when displaying it.
can I paste generated unix timestamps directly into a SQL INSERT?
Yes — if the column is an INT or BIGINT, paste the values in as-is. For a TIMESTAMP or DATETIME column in MySQL, wrap each value with FROM_UNIXTIME(ts); in PostgreSQL use TO_TIMESTAMP(ts). Choose seconds format for SQL in almost every case unless your schema explicitly stores millisecond epoch values in a BIGINT column.
Seconds or milliseconds — which Unix timestamp should I use?
It depends on your stack: Unix time is traditionally in seconds (a 10-digit number), but JavaScript's Date.now() and many APIs use milliseconds (13 digits). Match what your code expects — passing milliseconds where seconds are expected puts dates thousands of years in the future. The generator offers both; pick the format your system uses.
How do I convert a Unix timestamp back to a readable date?
In JavaScript, new Date(timestamp * 1000) for seconds (or new Date(timestamp) for milliseconds); in Python, datetime.fromtimestamp(timestamp); in SQL, functions like to_timestamp() (PostgreSQL) or FROM_UNIXTIME() (MySQL). The generated values drop straight into these. Just be sure you are using the right unit (seconds vs milliseconds).
You might also like
Popular tools from other categories that share themes with this one.
Try these next
More free tools from other corners of the catalog, picked by shared themes.