HOW-TO

How to convert a date to a Unix timestamp

Turn a human date into epoch seconds (or milliseconds) for APIs, JWTs, and databases. Free two-way converter plus the code one-liners.

Converting a date to a Unix timestamp gives you the single UTC number that APIs and databases prefer to store. Here is how to do it online and in code, including the seconds-vs-milliseconds choice.

Seconds or milliseconds

Decide which your target expects. Classic Unix time is seconds (10 digits); JavaScript’s Date.now() and many APIs use milliseconds (13 digits). Pick one and be consistent — mixing them is the most common timestamp bug.

In code

JavaScript: Math.floor(Date.now()/1000) for seconds, or new Date(str).getTime() for ms. Python: int(datetime.now(timezone.utc).timestamp()). Go: time.Now().Unix(). Always work in UTC to avoid timezone drift.

Step by step

1

Open the timestamp converter and enter your date (in UTC to avoid ambiguity).

2

Read the Unix timestamp it produces.

3

Choose seconds or milliseconds to match what your API/database expects.

4

In code, use Math.floor(Date.now()/1000) (JS) or datetime.timestamp() (Python).

Try it now — free, no signup

Use the timestamp converter in your browser. Then, when you need it at scale with an API key and higher limits, grab the full Eveses API.

FAQ

Should I use seconds or milliseconds?›
Match your target: classic Unix time is seconds; JavaScript and many web APIs use milliseconds.
Does the timezone matter?›
The timestamp is UTC. Enter the date as UTC (or account for the offset) so the resulting number is correct.

Related