Skip to content
86% off$349 $48.86code BF2026

Guides

How to Convert a Unix Timestamp on Mac (Terminal and Apps)

Convert a Unix timestamp on Mac with the BSD date command (date -r, date +%s), plus milliseconds, other epochs, date math and batch log lines.

GuideUpdated 8 min read

On this page

To convert a Unix timestamp on a Mac, open Terminal and run date -r 1700000000. It prints the date in your local time. For UTC, add -u (date -u -r 1700000000). For the current timestamp, run date +%s.

Many guides tell you to use date -d @1700000000. That is GNU date syntax from Linux. macOS ships the BSD date, which doesn't accept it and prints an error such as illegal option -- d. The commands below are the BSD versions, and they work on macOS 14 Sonoma, 15 Sequoia and 26 Tahoe.

Get the current Unix timestamp (epoch time) with date +%s

bash
date +%s

This prints the number of seconds since 1970-01-01 00:00:00 UTC. The number is the same in every time zone, so you don't need -u.

date +%s only gives whole seconds. If an API expects milliseconds, multiply in the shell:

bash
echo $(( $(date +%s) * 1000 ))

This prints the current time in milliseconds, but the last three digits are always 000. Bytepliers can also give you the current time in milliseconds: the Now menu in its Unix Timestamp tool has Unix Milliseconds, and bytepliers ts prints a unix-ms value. Both are covered below.

Convert a Unix timestamp to a date with date -r

bash
date -r 1700000000

This prints the date and time in your Mac's time zone. For UTC:

bash
date -u -r 1700000000

This prints Tue Nov 14 22:13:20 UTC 2023.

To control the output format, add a + format string at the end:

bash
date -u -r 1700000000 "+%Y-%m-%dT%H:%M:%SZ"

This prints ISO 8601 in UTC: 2023-11-14T22:13:20Z. For local time with the UTC offset:

bash
date -r 1700000000 "+%Y-%m-%d %H:%M:%S %z"

-r expects whole seconds. Don't include a decimal point, letters or a millisecond value. Milliseconds are covered in the table further down.

Convert a date to a timestamp with date -j -f

bash
date -j -f "%Y-%m-%d %H:%M:%S" "2026-11-11 10:00:00" +%s

This reads the date in your local time zone and prints Unix seconds. -j tells date not to set the system clock. -f gives the input format, and your text must match it exactly.

To read the date as UTC instead, set the time zone for that one command:

bash
TZ=UTC date -j -f "%Y-%m-%d %H:%M:%S" "2026-11-11 10:00:00" +%s

Any field you leave out of the format is taken from the current time. If you parse only "%Y-%m-%d", the hour, minute and second come from right now, so the result changes every time you run the command. Always include the time, even if it's 00:00:00.

Milliseconds, microseconds and other epochs

JavaScript's Date.now(), many APIs and many log systems use milliseconds, not seconds. For present-day dates, the number of digits tells you the unit:

DigitsUnitExampleConvert with date
10seconds1700000000date -r 1700000000
13milliseconds1700000000123date -r $(( 1700000000123 / 1000 ))
16microseconds1700000000123456date -r $(( 1700000000123456 / 1000000 ))
19nanoseconds1700000000123456789date -r $(( 1700000000123456789 / 1000000000 ))

The $(( )) arithmetic drops the fraction, so the output is accurate to the second.

Some platforms count from a different starting point. To turn their values into Unix seconds:

EpochCountsStartsTo Unix seconds
Apple reference (Cocoa, Core Data)seconds2001-01-01 UTCadd 978307200
Windows FILETIME100-nanosecond intervals1601-01-01 UTCdivide by 10,000,000, then subtract 11644473600
Excel serial datedays1899-12-30subtract 25569, then multiply by 86,400

For example, to convert an Apple reference date:

bash
date -u -r $(( 721692000 + 978307200 ))

Excel serial dates usually have a fractional part, and shell arithmetic only handles whole numbers. For Excel values, .NET ticks and FILETIME, the Bytepliers tool in the next section is easier.

Convert timestamps in Bytepliers

Bytepliers is our Mac app of offline developer tools. Its Unix Timestamp tool shows a value in several formats at once, so you don't have to remember format strings or work out the unit yourself.

  1. Open Bytepliers and press ⌘7 (Command-7), or click Unix Timestamp in the sidebar.
  2. Paste a timestamp or date into the input field.
  3. Read the output rows: Local, UTC, ISO 8601, ISO 8601 local, Relative, Unix seconds and Unix ms.
Unix Timestamp tool with 1700000000 entered, showing Local, UTC, ISO 8601 and Relative rows

The tool accepts:

  • Epoch seconds, milliseconds, microseconds or nanoseconds. It works out the unit from the number.
  • ISO 8601, yyyy-MM-dd HH:mm:ss and RFC 2822 dates.
  • Numbers with digit separators (commas, underscores or spaces). It ignores the separators.

The Numbers picker sets how a bare number is read. The choices are Auto (Unix) (the default), Unix Seconds, Unix Milliseconds, Unix Microseconds, Unix Nanoseconds, Apple Reference, Windows FILETIME, .NET Ticks and Excel Serial Date. In Auto mode, a Could also be row lists other readings of the same number, which helps when you don't know which epoch a value uses.

The Format row takes a custom ICU date pattern. Its Presets menu has RFC 2822, RFC 3339, HTTP Date (GMT), SQL Datetime, Go UnixDate and Go RFC1123Z.

For the current time, look at the input header, which shows the live "now" epoch. You can also use the Now menu. Clicking it inserts Unix seconds, and the menu also has Unix Seconds, Unix Milliseconds, ISO 8601 and Copy Current Timestamp.

If the tool can't read your input, it shows "Not a timestamp, date or expression".

Convert from any app with the Quick Panel

For a quick lookup, you don't need to switch apps:

  1. Copy the timestamp in any app.
  2. Press ⌥⌘B (Option-Command-B).
  3. Read the result. The Quick Panel shows the local time, plus UTC, ISO 8601, relative time and the epoch value.
  4. Press ⏎ to copy the result and close the panel, or ⎋ to close without copying.

To replace the clipboard contents directly, press ⌥⇧⌘B (Detect & Replace Clipboard). A timestamp becomes ISO 8601, and a date becomes Unix seconds. To undo, choose Tools ▸ Restore Previous Clipboard. You can change both shortcuts in Settings ▸ Shortcuts. The Quick Panel and Instant Replace docs cover both in detail.

Convert from Terminal with bytepliers ts

Bytepliers includes a command-line tool. Install it from Settings ▸ Integrations ▸ Command-Line Tool ▸ Install… (see the bytepliers command-line tool). Then run:

bash
bytepliers ts 1700000000

This prints five values: unix, unix-ms, iso-utc, iso-local and relative. Run bytepliers ts with no value to get the same fields for the current time. You can also pass a date instead of a number.

The command works when the app isn't running. It does need a license or an active trial, and you must have opened Bytepliers at least once.

Do date math: now + 90 minutes, 30 days ago

BSD date adjusts dates with -v:

bash
date -v+90M

This prints the time 90 minutes from now.

bash
date -v-30d +%s

This prints the Unix timestamp for 30 days ago.

bash
date -u -r 1700000000 -v+1d

This prints the time one day after a given timestamp, in UTC.

The units are y (years), m (months), w (weeks), d (days), H (hours), M (minutes) and S (seconds). Case matters: -v+90m adds 90 months, not 90 minutes. You can combine adjustments, for example date -v+1d -v-2H.

In Bytepliers, type the expression straight into the Unix Timestamp input:

  • now + 90m
  • 1700000000 + 86400
  • 2026-11-11 - 30d

The units are s, m, h, d and w, and * and / also work. Here m means minutes, which is the opposite of date. You can also type today, tomorrow and yesterday.

Convert many log lines at once

If a file has one timestamp per line, loop over it in Terminal:

bash
while read -r ts; do date -u -r "$ts" "+%F %T"; done < timestamps.txt

This prints each timestamp as a UTC date and time. The file isn't changed.

If the timestamp is the first field of each log line and you want to keep the rest of the line:

bash
while read -r ts rest; do echo "$(date -u -r "$ts" '+%F %T') $rest"; done < app.log

For millisecond timestamps, replace "$ts" with $(( ts / 1000 )).

In Bytepliers, paste several lines into the Unix Timestamp tool and you get a Table with the columns Input, Local, ISO 8601 (UTC), Unix and Relative. It reads up to 5,000 lines. You can copy the table as tab-separated values and paste it into a spreadsheet. The tool expects one timestamp per line, so if the timestamps are inside longer log lines, extract that column first, for example with cut -d' ' -f1 app.log | pbcopy.

Unix Timestamp batch table converting five lines: epoch seconds, milliseconds and an ISO 8601 date
Several lines make a table.

See the time in other zones

In Terminal, set TZ for a single command:

bash
TZ=America/New_York date -r 1700000000

This prints the timestamp in New York time. Zone names come from the tz database. To list the names your Mac knows, run ls /usr/share/zoneinfo.

In Bytepliers, open Zones in the Unix Timestamp tool and click Add Zone to choose from a searchable list of cities and zones. The zones you add are saved, so they're still there the next time you open the tool.

Which method to use

MethodBest forMilliseconds and other epochsBatchNeeds
date in TerminalScripts, one-off checksManual division and offsetsShell loopNothing, built in
Bytepliers Unix Timestamp toolSeeing every format at once, unknown epochsAuto-detected, plus a pickerUp to 5,000 lines as a tableBytepliers
Quick Panel (⌥⌘B)Checking a copied value from any appAuto-detectedNoBytepliers
bytepliers tsFive formats in Terminal at onceIncludes unix-msShell loopBytepliers CLI installed

If you only convert a timestamp now and then, date -r is all you need. Bytepliers helps if you convert timestamps every day, deal with milliseconds or Apple, Windows and Excel dates, or want the answer without leaving the app you're in. Bytepliers is part of MacSuite, and you can try it free for 7 days.

If it doesn't work

  • illegal option -- d or a usage message: You used GNU syntax (date -d @…). On macOS, use date -r <seconds>. If you've installed GNU coreutils with Homebrew, the GNU version is available as gdate.
  • The year is five digits (tens of thousands of years from now): You passed milliseconds as seconds. Divide by 1,000 first: date -r $(( value / 1000 )).
  • The time is off by several hours: date shows local time by default. Add -u for UTC, or set TZ= for a specific zone.
  • date -j -f gives a different result each run: The format leaves out the time or seconds, so those fields come from the current time. Include every field in both the format and the input.
  • date -j -f says the conversion failed: The input doesn't match the format exactly. Check the separators, the T in ISO dates and any time zone suffix.
  • date -f complains it isn't permitted: You left out -j, so date tried to set the system clock. Add -j.

FAQ

Is a Unix timestamp always UTC?

Yes. It counts seconds since 1970-01-01 00:00:00 UTC, so a given moment has the same timestamp everywhere. Time zones only matter when you display it as a date.

Does JavaScript use seconds or milliseconds?

Milliseconds. For current dates, Date.now() returns a 13-digit number. Divide it by 1,000 before passing it to date -r.

Will my Mac have a problem in 2038?

The 2038 limit (2038-01-19 03:14:07 UTC) applies to 32-bit signed timestamps. macOS uses 64-bit time values, so date on a current Mac handles dates well past 2038. Older systems and file formats that store 32-bit values can still overflow.

For related tools, see how to generate a UUID on Mac and the Bytepliers tool reference.

Every app.
One purchase.