ThisCalculator

Everyday

Set System Time Mac OS X Command Line

Updated · Standard formula, shown below

Set System Time Mac OS X Command Line

To set the system time from the command line in macOS, you use the date command with root privileges, for example: sudo date 042510302025.15 sets the date to April 25, 2025, 10:30:15 AM. The syntax is date [[[mm]dd]HH]MM[[cc]yy][.ss], and you must run it with sudo because changing the system clock requires administrator rights.

Why Use the Command Line to Set Time?

Most Mac users set the clock through System Settings (or System Preferences in older versions), but the command line offers several advantages. It is faster for scripting and automation, allows precise control down to the second, and is essential when working on a headless Mac (e.g., a server accessed via SSH) where the GUI is not available. It also works in recovery mode or single-user mode when the graphical interface is not loaded.

How the date Command Works

The date command in macOS (which is based on BSD) accepts a specific format for setting the time. The format is built from two-digit fields:

  • mm – month (01–12)
  • dd – day of month (01–31)
  • HH – hour (00–23, 24-hour format)
  • MM – minute (00–59)
  • cc – century (first two digits of the year, e.g., 20 for 2025)
  • yy – year within century (00–99)
  • .ss – seconds (00–60, optional)

You can omit trailing fields; they default to the current value. For example, date 04251030 sets the month, day, hour, and minute but leaves the year and seconds unchanged. If you omit the century, macOS assumes the current century (e.g., 2025). The date command also accepts a string like date "042510302025.15" (with quotes) to avoid shell misinterpretation of the dot.

Step-by-Step: Setting the Time

  1. Open Terminal (found in /Applications/Utilities/).
  2. Type date and press Enter to see the current system date and time. This helps you confirm the format.
  3. Construct your desired time string. For example, to set the date to July 4, 2025, at 9:15:30 AM, you would use: 072509152025.30 (month=07, day=25, hour=09, minute=15, year=2025, seconds=30).
  4. Run the command with sudo: sudo date 072509152025.30
  5. Enter your administrator password when prompted.
  6. Verify with date again.

Note that the hour is in 24-hour format. For 3:45 PM, use 15 for the hour, not 3.

Common Mistakes and Pitfalls

The most frequent error is mixing up the order of fields. The format is month, day, hour, minute, year, not the more intuitive year-month-day. Another common mistake is forgetting the sudo – you will get a “Operation not permitted� error. Also, be aware that the date command sets the system clock, not just the time zone display. If you have automatic time zone detection enabled, macOS may immediately correct your manual setting when it contacts network time servers. To prevent this, you can disable automatic time setting in System Settings > General > Date & Time (or System Preferences > Date & Time) before using the command line.

Alternatives: systemsetup and ntpdate

There are other command-line tools for time management. The systemsetup command can set the date and time using a more human-readable format, e.g., sudo systemsetup -setdate 07/25/2025 and sudo systemsetup -settime 09:15:30. This is often easier to remember. For syncing with a network time server, you can use sudo sntp -sS time.apple.com (or the older ntpdate if installed). The sntp command is built into macOS and is the modern replacement for ntpdate.

Safety and Precautions

Changing the system time can affect many things: scheduled tasks (cron jobs), SSL certificate validation, file timestamps, and even the behavior of some applications. If you set the time to a date in the past, you may see certificate errors when browsing the web. If you set it to the future, email clients might mark messages incorrectly. Always verify the time after setting it, and consider using sudo sntp -sS time.apple.com to restore accurate time from a network server. Also, be aware that in macOS, the system time is stored as the number of seconds since January 1, 2001 (the “reference date� for macOS), but the date command handles the conversion for you.

Frequently Asked Questions

Can I set the time without sudo?

No. Setting the system clock is a privileged operation. You must use sudo or be logged in as the root user. If you are not an administrator, you cannot change the time.

What is the difference between date and systemsetup?

The date command is a standard Unix utility that accepts the compact field format described above. systemsetup is a macOS-specific tool that offers more human-readable options like -setdate mm/dd/yyyy and -settime hh:mm:ss. Both require root privileges and achieve the same result.

Why does my Mac revert to the wrong time after I set it?

If you have automatic time and date setting enabled, macOS will periodically query network time servers and override your manual changes. Disable “Set time and date automatically� in System Settings > General > Date & Time (or System Preferences > Date & Time) to keep your manually set time.

How do I set the time zone from the command line?

You can use sudo systemsetup -settimezone America/New_York (replace with your time zone). To list available time zones, use sudo systemsetup -listtimezones. The date command does not set the time zone.

What if I set the time incorrectly and break my Mac?

You won’t break the hardware, but you might cause temporary issues with SSL certificates, cron jobs, or file timestamps. To fix it, simply set the correct time using the same command, or run sudo sntp -sS time.apple.com to sync with Apple’s time server. If you are in a boot loop, you can boot into Recovery Mode and use the Terminal there to set the time.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.