Days between dates

Date to Unix timestamp

Pick a date and time and the time zone it is in. The timestamp appears in seconds and milliseconds.

How it is worked out

The date and time are read in the time zone you pick, turned into an instant, and counted in seconds from 00:00:00 UTC on 1 January 1970.

The time zone matters: 09:00 on 1 March 2027 in Berlin (UTC+1) is 1803888000, the same clock time in UTC is 1803891600, an hour later. Pick UTC when the time came from a server or a log, your own zone when it is a time you live by.

On the night summer time ends, one hour happens twice; the converter takes the first. On the night it starts, one hour does not exist, and the time is moved past the gap.

In code

JavaScript: Math.floor(new Date('2027-03-01T09:00:00Z').getTime() / 1000).
Python: int(datetime(2027, 3, 1, 9, tzinfo=timezone.utc).timestamp()).
PostgreSQL: EXTRACT(EPOCH FROM TIMESTAMPTZ '2027-03-01 09:00:00+00').
Shell (GNU): date -d '2027-03-01 09:00 UTC' +%s.

To add time to a timestamp, add seconds: one day is 86,400. Use a date library for months, since they differ in length.

Seconds in common units

UnitSecondsMilliseconds
Minute6060,000
Hour3,6003,600,000
Day86,40086,400,000
Week604,800604,800,000
Month (average)2,629,7462,629,746,000
Year (average)31,556,95231,556,952,000
Decade (average)315,569,520315,569,520,000

A month is an average Gregorian month (30.44 days), a year an average Gregorian year (365.2425 days).

Worked example: a token that expires in an hour

A login token is issued at 09:00 UTC on 1 March 2027, Unix time 1803891600. It should expire an hour later, so its exp field is 1803891600 + 3600 = 1803895200; a day later would be + 86400 = 1803978000.

JSON Web Tokens and most APIs count in seconds; JavaScript’s Date and Java count in milliseconds, three digits longer: 1803891600000. A timestamp with 13 digits is in milliseconds.

Old systems that store Unix time in a signed 32-bit number run out at 2147483647, 03:14:07 UTC on 19 January 2038, and wrap round to 1901.

Unix time at the start of each month of 2027

00:00 UTC onSecondsMilliseconds
January 1, 202717987616001798761600000
February 1, 202718014400001801440000000
March 1, 202718038592001803859200000
April 1, 202718065376001806537600000
May 1, 202718091296001809129600000
June 1, 202718118080001811808000000
July 1, 202718144000001814400000000
August 1, 202718170784001817078400000
September 1, 202718197568001819756800000
October 1, 202718223488001822348800000
November 1, 202718250272001825027200000
December 1, 202718276192001827619200000

Each day adds 86,400 seconds; Unix time ignores leap seconds.

Sources

IEEE Std 1003.1 (POSIX), Base Definitions, “Seconds Since the Epoch”.
RFC 7519, JSON Web Token: the NumericDate of the iat and exp claims, in seconds.

Written by the ufactory team and checked in November 2026.

Questions

  • Seconds or milliseconds?

    Unix tools, PHP, Python and most databases use seconds. JavaScript and Java use milliseconds. The converter gives both.

  • What is the timestamp for midnight today?

    Set the time to 00:00 and pick your time zone; midnight UTC is a different instant unless you live on UTC.

  • Which calculator do I need?

    Seven calculators: days between two dates, add or subtract days, the countdowns to New Year, Thanksgiving and Black Friday, a Unix timestamp to a date and a date to a Unix timestamp. Each answers as you type, and the share bar links the calculation.