TechEarl

How to Set the Date and Time From the macOS Command Line

Set the system clock from the macOS command line the right way. The BSD date set form is MMDDhhmm[[CC]YY], not the date -I flag that gets copied around (that one only formats output). Turn off network time first or macOS resyncs.

Ishan KarunaratnePublished ⏱️ 10 min readUpdated
Share thisCopied
Set the macOS clock from Terminal with the BSD date command: MMDDhhmm[[CC]YY], not date -I (an ISO 8601 output flag that sets nothing). Turn off network time first or macOS resyncs.

On macOS, you set the system clock from the command line with the BSD date command and a bare numeric argument:

bash
# Set the clock to 2026-06-14, 12:00:
sudo date 0614120026

That is it. The number is MMDDhhmm[[CC]YY][.ss]: two digits each of month, day, hour (24-hour), and minute, then an optional year, then optional seconds. No flags, no separators. You need sudo because the system clock is root-owned.

The reason this article exists is that the most-copied answer on the internet is wrong. You will see sudo date -I 06142024 passed around as the way to set the date on a Mac. It is not. -I is the ISO 8601 output flag, on GNU date and on the current macOS date alike, and it has nothing to do with setting anything. Run that command and the trailing number is misread as month, day, hour, and minute, so you never get the clock you wanted. Below is the correct form, field by field, plus the one step everyone forgets: turning off network time first, or macOS quietly puts the clock back where it was.

The BSD date set syntax, field by field

macOS uses the BSD userland, so date is the BSD utility, not GNU coreutils. Its full set form is a single positional number. The man page writes it as:

bash
sudo date [[[mm]dd]HH]MM[[cc]yy][.ss]

Read left to right, the eight common digits spell out MMDDhhmm:

FieldMeaningDigits
MMMonth (01-12)2
DDDay of month (01-31)2
hhHour, 24-hour (00-23)2
mmMinute (00-59)2
CCCentury, optional (e.g. 20)2
YYYear within century, optional (e.g. 26)2
.ssSeconds, optional, after a dot2

Strictly speaking, the only mandatory field is the minutes (the man synopsis nests every field to the left of MM as optional: [[[mm]dd]HH]MM), and the century, year, and seconds on the right are optional too. In practice you almost always type the full MMDDhhmm block plus a year, because setting the minute alone (sudo date 30) just moves the clock to minute 30 of the current hour, which is rarely what you want. Any field you omit defaults to its current value. So a worked example for June 14, 2026 at 12:00:30:

bash
sudo date 0614120026         # MMDDhhmm + YY  (year shorthand: 26)
sudo date 061412002026       # MMDDhhmm + CCYY (full year: 2026)
sudo date 061412002026.30    # ...with seconds (.30)

If you drop the year entirely (sudo date 06141200) the command keeps the current year and just changes the month, day, hour, and minute. To read the clock without touching it, run date with no argument and no sudo.

A common stumble: the field order is month first, then day, not day-month. 0614 is June 14, not the 6th of the 14th month. If you are coming from a DD/MM locale, that flip is the first thing to double-check.

Why date -I does not set anything

This is the wrong-source correction worth internalising. The -I form circulates because Linux examples leak onto Mac how-tos, and the two date commands are not the same program:

  • GNU date (Linux) uses -d/--date and -s/--set to interpret and set time, and -I/--iso-8601 to print the date in ISO-8601 format. -I is an output formatter. It never sets the clock, even on Linux.
  • BSD date (macOS) sets the clock with the bare MMDDhhmm[[CC]YY] string shown above. It has no --set flag. The current macOS date does accept -I[FMT] (its man page: "Use ISO 8601 output format", added upstream in FreeBSD 12.0), but with the same meaning as on Linux: it only changes how the date is printed.

So here is what sudo date -I 06142024 really does on a current Mac. -I switches the output to ISO 8601, and the trailing 06142024 is then parsed by the normal set syntax as MMDDhhmm: June 14, 20:24, in the current year. The clock does move, just not to 2024 and not to the time you had in mind. I checked the parsing on macOS 26 with the no-set flag: date -j -I 06142024 prints 2026-06-14, and date -j 06142024 prints Sun Jun 14 20:24:00 EDT 2026. On a macOS old enough that its date predates the flag, the same command fails on the unknown option instead. Either way, -I is not what sets anything.

If you genuinely want GNU date semantics on a Mac (the -d "next friday" style parsing, --iso-8601 output, and so on), install coreutils and use gdate:

bash
brew install coreutils
gdate -d "2026-06-14 12:00" "+%Y-%m-%d %H:%M"   # GNU date, prefixed g

Reach for gdate for the parsing and formatting that people actually want -I for. To actually move the macOS system clock, stick with the BSD sudo date MMDDhhmm… form above: it is the documented, dependable way on macOS, where the BSD date is what the OS ships and supports.

Turn off network time first, or macOS resyncs

Here is the step that makes manual setting look broken when you skip it. By default macOS keeps the clock synced over the network (NTP), so the moment you set the date by hand, the time service notices the drift and silently corrects it back. Your sudo date worked; the OS just undid it seconds later.

Disable automatic network time before you set the clock:

bash
sudo systemsetup -setusingnetworktime off
sudo date 0614120026

Check the current setting any time with sudo systemsetup -getusingnetworktime. While network time is off the clock holds whatever you set, which is exactly what you want for testing.

When you are done, turn it back on and macOS resyncs to the correct real time immediately:

bash
sudo systemsetup -setusingnetworktime on

That resync is the clean reset: you do not have to figure out the right current time by hand, the time service does it for you. If you want a one-shot correction without toggling the setting, use sntp instead, which is the NTP client macOS ships (it replaced ntpdate, removed back in macOS 10.14 Mojave):

bash
sudo sntp -sS time.apple.com

On the macOS build, -s slews the clock with adjtime(2) when the offset is small (under 50 ms) and -S steps it with clock_settime(2) when the offset is larger, so passing both lets sntp pick the right correction for the size of the drift; time.apple.com is Apple's own NTP host. This pulls the real time once and leaves the network-time setting where it was.

While you are in systemsetup, sudo systemsetup -settimezone "America/New_York" sets the timezone (list valid zones with sudo systemsetup -listtimezones), which is a separate concern from the clock value but often comes up in the same breath.

The actual use case: testing date-based logic

Almost nobody sets the Mac clock because they think it is wrong. They set it to test code that behaves differently on a certain date: a subscription that expires, a coupon that activates next week, a cron-style job, a "your trial ends in 3 days" banner, a certificate that goes stale. Moving the system clock forward is the brute-force way to see that path fire.

The brute-force way has a cost, though: every other app on the machine now thinks it is a different day, your TLS handshakes may fail, and if you forget to turn network time back on you are debugging a "wrong clock" for the rest of the afternoon. So the disciplined version is: turn network time off, set the date, run your test, turn network time back on. Keep that loop tight.

If you find yourself doing this often, a tool like libfaketime is worth a look: it intercepts time calls for a single process rather than moving the whole machine's clock, so you never touch the real system time at all. That is the cleaner long-term answer for repeatable date-based tests, while sudo date is the quick one-off.

Because -I is an ISO 8601 output option, on GNU date and on the current macOS BSD date alike: it changes how a date is printed and never sets one. In sudo date -I 06142024, macOS reads the trailing number with its own set syntax as month, day, hour, and minute (June 14, 20:24, current year), not as a date in 2024. Set the clock with the bare numeric form instead: sudo date 0614120026.

The BSD set form is MMDDhhmm with an optional year and seconds: month, day, hour (24-hour), minute, then optionally century, year, and a dot plus seconds. For 2026-06-14 12:00 that is sudo date 0614120026 (two-digit year) or sudo date 061412002026 (full year).

macOS keeps the clock synced over the network, so it corrects your manual change within seconds. Run sudo systemsetup -setusingnetworktime off before you set the date, and sudo systemsetup -setusingnetworktime on afterwards to resync to the real time.

Yes. The system clock is owned by root, so changing it requires sudo. Reading the clock does not: plain date with no arguments prints the current date and time without elevation.

Install coreutils with Homebrew (brew install coreutils) and use gdate, which is GNU date under a prefixed name. It gives you -d "next friday" parsing and --iso-8601 output. Use it for parsing and formatting; to set the macOS clock, stay on the BSD sudo date 0614120026 form, which is the documented way on macOS.

See also

Sources

Authoritative references this article was fact-checked against.

TagsmacOSBSD datedate commandTerminalCLIsystem clocksudo

Found this useful? Pass it on.

Copied

Ishan Karunaratne

Systems and Network Architect · Chief Technology Officer

Systems and network architect and Chief Technology Officer with more than two decades designing, building, and running production software, cloud and network architecture, Linux systems, and the bare metal underneath them, and lately working AI into the stack. A US Army veteran who served in Operation Iraqi Freedom. What I write here is drawn from the full arc of that work, across architecture, engineering, and operations, not any single job.

Keep reading

Related posts

Toggle macOS dark mode from the terminal with one osascript line, set the volume, turn Bluetooth on or off, take a camera photo and read your calendar.

How to Toggle Dark Mode From the macOS Command Line

Toggle macOS dark mode from the terminal with one osascript line: instant, no restart. Force it on or off, read the current state, and skip the dead _HIEnableThemeSwitchHotKey trick. Plus the other Mac settings from the command line: system volume (osascript), Bluetooth (blueutil), a photo with the Mac camera (imagesnap) and your calendar (cal, icalBuddy).

Encode and decode a file with the base64 command. The macOS vs GNU gotchas (bare filename vs -i, the -D vs -d decode flag), 76-column wrapping, and an image data URI in one line.

How to Base64-Encode or Decode a File From the Command Line

Base64-encode and decode a file from the terminal with the built-in base64 command. The macOS-vs-GNU gotchas (macOS wants -i or stdin instead of a bare filename, and the -D vs -d decode flag on older Macs), the line-wrapping difference, and building a data URI from an image.