Language
English English Vietnamese (Tiếng Việt) Vietnamese (Tiếng Việt) Chinese (简体中文) Chinese (简体中文) Portuguese (Brazil) (Português do Brasil) Portuguese (Brazil) (Português do Brasil) Spanish (Español) Spanish (Español) Indonesian (Bahasa Indonesia) Indonesian (Bahasa Indonesia)
Seconds to Days

Seconds to Days

Turns a raw epoch-seconds field into a day number you can read at a glance, with the landmark timestamps and the signed 32-bit ceiling that ends in 2038.

Ten Digits in a Column That Are Really a Date

Somewhere in almost every log line, database row and API payload there is a bare integer standing in for a moment in time. It is the number of seconds since midnight UTC on 1 January 1970, and it is stored that way because a single integer sorts, subtracts and indexes without any of the trouble a formatted date brings. The cost is that nobody can read it. Dividing by 86 400 turns that integer into a day number, and a day number is close enough to a date that you can reason about it while you are still looking at the query results.

Conversion factor: 1 d = 86 400 s, so divide seconds by 86 400. A timestamp of 1 700 000 000 is 19 675.9259 days after the epoch: 19 675 whole days lands on 14 November 2023, and the leftover 0.9259 d — 80 000 s — is 22:13:20 UTC.

What the Day Number Is Good For

Sanity-checking a suspicious value

A day count near 20 000 is a plausible recent date. One in the millions means the field was milliseconds, and one near zero means something defaulted to the epoch instead of being written.

Measuring an age, not a moment

Subtract two timestamps and the difference is a duration in seconds. Divided by 86 400 it becomes record age, token lifetime or retention window in the unit a policy is written in.

Spotting a ceiling before it arrives

The signed 32-bit limit sits at 2 147 483 647, which is day 24 855 — a finite distance away, and worth knowing when a value is stored in a four-byte column.

No timezone in the number

Epoch seconds are always UTC. Whatever offset a screen applies afterwards is presentation; the stored integer never moves, which is exactly why systems keep it in this form.

Getting From a Raw Field to Something Readable

The workflow is one paste and one glance, usually in the middle of debugging something else entirely.

1

Paste the field exactly as it appears

Drop 1 700 000 000 or 1 234 567 890 into the left box. Spaces are ignored and a comma is read as a decimal point, so a value copied out of a formatted table needs no tidying first.

2

Count the digits before you trust it

Ten digits is seconds and lands in the tens of thousands of days. Thirteen digits is milliseconds and will come back as tens of millions of days — switch the left dropdown to milliseconds and the result falls back into range.

3

Reverse it to build a range boundary

The swap button (↔) gives d → s, which is what you want when a retention rule says 90 days and the query needs 7 776 000 seconds subtracted from now.

4

Copy digits straight into the shell

The copy control hands over the bare number with no unit and no spacing, ready to paste after a date -d @ or into a where-clause. Ctrl + C in a field behaves the same.

Do not route a timestamp through the year unit: the year in the dropdown is a fixed 365.2425 days and the month a fixed 30.4375, both averages. They give a usable age, never a calendar date. Keep timestamp work in seconds and days, where every step is exact.

Epoch Landmarks and the Day Numbers Behind Them

The values that show up in test fixtures, overflow discussions and screenshots of odometer-watching, each with the day count it divides into and the UTC moment it names.

Landmark Epoch seconds Days since epoch UTC date and time
The epoch itself001970-01-01 00:00:00
One billion seconds1 000 000 00011 574.072001-09-09 01:46:40
The counting-digits moment1 234 567 89014 288.982009-02-13 23:31:30
1.5 billion seconds1 500 000 00017 361.112017-07-14 02:40:00
Two billion seconds2 000 000 00023 148.152033-05-18 03:33:20
Signed 32-bit ceiling2 147 483 64724 855.132038-01-19 03:14:07
Unsigned 32-bit ceiling4 294 967 29549 710.272106-02-07 06:28:15

Read down the day column and the shape of the problem is obvious: the whole usable range of a signed four-byte timestamp is under twenty-five thousand days, and we have already spent more than three-quarters of it. Treating the field as unsigned buys another 24 855 days and pushes the wall to 2106, but it also throws away every date before 1970 — which is why the real fix everywhere is a 64-bit field rather than a clever reinterpretation of the old one.

What This Pair Does While You Are Debugging

Paste, glance, carry on

The day count appears while you type, so identifying a stale row or a bogus default costs one paste rather than a detour into a language REPL.

Millisecond fields on the same page

Change the left dropdown to milliseconds and a thirteen-digit value converts without leaving the tab — the fastest way to settle which unit a mystery column is in.

Retention windows the other way

Swap the pair and a policy stated in days becomes the second offset a cut-off query subtracts, so both halves of the job live on one screen.

Fractions of a day survive

Up to eight decimals are kept, so the part after the decimal point is still the time of day rather than something rounded away — 0.5 is noon, 0.75 is 18:00.

Questions About Epoch Time and the 2038 Rollover

My field says 1700000000 — is that seconds or milliseconds?

Count the digits. Ten digits is seconds for any date between 2001 and 2286, and 1 700 000 000 divides into 19 675.93 days — a perfectly sensible November 2023. Thirteen digits is milliseconds, the convention in JavaScript, Java and most JSON APIs that were designed around them; run those through the seconds side and you get roughly 19.7 million days, about 53 000 years, which is the tell. Nanosecond fields with nineteen digits turn up in tracing and time-series systems. When a column mixes the two, the mismatch usually shows as records dated either just after 1970 or somewhere in the far future.

What actually happens to a 32-bit system in January 2038?

At 03:14:07 UTC on 19 January 2038 a signed 32-bit counter reaches 2 147 483 647, its largest representable value. One tick later it wraps to −2 147 483 648, which reads as 20:45:52 UTC on 13 December 1901. Systems then either report dates in the early twentieth century or refuse to advance at all, and anything doing date arithmetic — certificate validity, scheduling, billing periods — starts producing negative durations. The signed type is a deliberate early choice so that pre-1970 dates could be expressed; it is also the reason the overflow lands in 1901 rather than back at the epoch. Sixty-four-bit time fields push the ceiling far beyond any practical horizon, so the exposure now lives in embedded devices, on-disk formats and network protocols with a four-byte field baked in.

Where do leap seconds go if every POSIX day is exactly 86 400 seconds?

They are not in the count at all. POSIX defines the value as a formula over calendar fields in which a day is always 86 400 seconds, so a leap second cannot be represented — the timestamp simply repeats a value or is nudged so the extra second disappears. That is why a division by 86 400 is exact here and never accumulates drift, and also why a POSIX timestamp is not a true count of elapsed SI seconds since 1970: it is behind atomic time by the number of leap seconds inserted since, which has been 27 since 1972. Many large operators avoid the discontinuity entirely by smearing the extra second across a whole day, making each second imperceptibly longer instead of repeating one.

Why does the day count come out with a decimal fraction?

Because the fraction is the time of day. A timestamp names an instant, not a date, so dividing it by 86 400 leaves a whole number of complete days plus however far into the current one the instant falls. Multiply the fraction back by 86 400 to get the seconds past midnight UTC: 0.25 is 06:00, 0.5 is noon, 0.9259 is 22:13:20. If you only want the calendar day, take the integer part and ignore the rest — but be careful doing that with negative values, where truncating toward zero and flooring disagree, which is a classic source of dates landing a day out for anything before 1970.

Can I work out the calendar date from a day number without a library?

You can get very close in your head and exact with a little care. Divide the day number by 365.2425 for the approximate elapsed years: 19 675.93 ÷ 365.2425 ≈ 53.87, so 1970 plus about 53.9 years puts you in late 2023, and 0.87 of a year is roughly day 318, which is 14 November. That matches the exact answer, but the method only works because the divisor is the average Gregorian year length; it will drift by a day or two around leap years and it is not a substitute for real date arithmetic. For an exact result, keep the day number as an offset from 1970-01-01 and let a date library — or date -d @1700000000 at a shell — add it, since that path counts real months and leap days instead of an average.

s
d

Epoch Landmarks in Days

86 400 s=1 d
1 000 000 000 s=11 574.07 d
1 234 567 890 s=14 288.98 d
1 500 000 000 s=17 361.11 d
2 147 483 647 s=24 855.13 d
4 294 967 295 s=49 710.27 d

Second (s)

The only unit POSIX time has: one integer counting from midnight UTC on 1 January 1970, with no timezone attached, which is why systems store instants this way and sort them without parsing anything.

Day (d)

Exactly 86 400 seconds by definition in POSIX, leap seconds included or not at all. That fixed length is what makes the division exact and what turns a ten-digit field into a readable day number.

Paste the raw field straight in — spaces are ignored and a comma reads as a decimal point
Ten digits is seconds, thirteen is milliseconds — switch the left unit if the day count runs into millions
Press swap (↔) for d → s when a retention window has to become a query offset
The decimal part is the time of day: 0.5 d is noon UTC, 0.75 d is 18:00 UTC
Want to learn more? Read documentation →
1/5

Time Converter

Centuries to Millenniums Centuries to Years Days to Hours Days to Minutes Days to Months Days to Seconds Days to Weeks Days to Years Decades to Centuries Decades to Years Hours to Days Hours to Minutes Hours to Months Hours to Seconds Hours to Weeks Hours to Years Microseconds to Milliseconds Microseconds to Nanoseconds Microseconds to Seconds Millennia to Years Millenniums to Centuries Milliseconds to Microseconds Milliseconds to Minutes Milliseconds to Seconds Minutes to Days Minutes to Hours Minutes to Milliseconds Minutes to Seconds Minutes to Years Months to Days Months to Hours Months to Weeks Months to Years Nanoseconds to Microseconds Nanoseconds to Seconds Seconds to Days (current page) Seconds to Hours Seconds to Microseconds Seconds to Milliseconds Seconds to Minutes Seconds to Nanoseconds Seconds to Years Weeks to Days Weeks to Hours Weeks to Months Weeks to Years Years to Centuries Years to Days Years to Decades Years to Hours Years to Minutes Years to Months Years to Seconds Years to Weeks
Start typing to search...
Searching...
No results found
Try searching with different keywords