Как изменить дату mac os через терминал

Часы в Mac OS X устанавливаются автоматически по умолчанию, но если вы хотите установить точное время или ищете решение командной строки для установки системного времени, вы можете сделать это с помощью инструмента под названием ntpdate или стандартной ‘date’ команда. Установка системной даты в Mac OS X из командной строки с центральным сервером времени Для ntpdate,...

Часы

Часы в Mac OS X устанавливаются автоматически по умолчанию, но если вы хотите установить точное время или ищете решение командной строки для установки системного времени, вы можете сделать это с помощью инструмента под названием ntpdate или стандартной ‘date’ команда.

Установка системной даты в Mac OS X из командной строки с центральным сервером времени

Для ntpdate, который устанавливает дату и время на основе времени с центрального сервера, доступного через Интернет, вам нужно указать его либо на серверы времени Apple, либо на pool.ntp.org, как показано ниже, чтобы получить точное время:

sudo ntpdate -u time.apple.com

Введите пароль администратора, когда его спросят, и вскоре вы увидите что-то вроде следующего:

4 Jul 14:30:11 ntpdate[28267]: adjust time server 17.151.16.14 offset 0.000336 sec

Смещение в конце позволяет узнать, насколько системные часы расходятся с недавно установленным временем. В этом примере системные часы были на смехотворно малую долю секунды.

Обычно вам не нужно этого делать, если вы используете функцию «Установить дату и время автоматически» в системных настройках даты и времени, хотя, установив часы через командную строку, вы можете быть уверены, что каждая машина в сети показывает точную то же время.

Установите системную дату Mac вручную с помощью команды терминала

Другой подход — установить дату вручную из командной строки с помощью командной строки «date», где дата находится в [mm][dd]ЧЧ]ММ[yy] формат, который представляет собой месяц, дату, час, минуту, год без какого-либо разделения. Это выглядит примерно так:

date 0712122318

В этом примере будет установлена ​​дата «12 июля 2018 г., 12:23».

Вы можете узнать больше об установке даты с помощью date –help, которая также указывает, что вы даже можете установить секунды, если хотите.

Уловка с «свиданием» — это то, что вы хотели бы использовать, если рассматриваемый Mac не имеет доступа в Интернет по той или иной причине.

Самое верхнее изображение, взятое из заставки Flipclock

The date and time on your Mac is not something that we often think about. Actually, most users leave their Mac on the default automatic setting it so it’s not something that we normally worry about. But there are situations where you might need to do this.

While it can be done through the Time and Date section in your desktop settings, some may want to change using Mac Terminal. Doing it through the terminal application is quite easy and can be done in just a few steps.

My name is Eric and as a Software Engineer, I perform tasks like this on a daily basis.  And I am still learning new things all the time. I love to do research on topics like this and I also enjoy learning from all the other users and readers out there.

If you want to learn about changing the date and time using Mac Terminal, keep reading and I will show you what I have learned.

Contents

  • Guide to Changing Date and Time on Mac via Terminal
    • Step 1: Open Mac Terminal
    • Step 2: Turn off the setusingnetworktime feature
    • Step 3: Figure out your date/time parameter 
    • Step 4: Use the date command to set the date and time.
    • Step 4: Verify the time was set
  • How to Change the Timezone on Mac Terminal
    • Step 1: View the List of Timezones
    • Step 2: Set the time zone 
    • Step 3: Verify the time zone has been set
  • FAQs
    • Why are the date and time wrong on my Mac?
    • Why won’t my Mac let me change the date and time?
    • How do I change the date format on my Mac?
  • Final Words

Guide to Changing Date and Time on Mac via Terminal

Note: Using the sudo command before each of these commands will often require you to enter your password. This should be the password for the admin account you are using.

Step 1: Open Mac Terminal

Step 2: Turn off the setusingnetworktime feature

Turn off setusingnetworktime by typing the following command into the Terminal: 

sudo systemsetup -setusingnetworktime off

Step 3: Figure out your date/time parameter 

Determine your date and time parameter using the format [MM][DD][HH][MM][YY]

Example: April 15, 2022, 11:00 am would be 0415110022

Note: The time uses a 24-hour format.

Step 4: Use the date command to set the date and time.

Type the following command into your Mac Terminal to set the date and time. 

sudo date [MM][DD][HH][MM][YY]

Using our example: sudo date 0415110022

Step 4: Verify the time was set

Type just the “date” command alone to verify the time was properly set. 

date

How to Change the Timezone on Mac Terminal

Setting the timezone from Mac Terminal is just as easy as setting the date and time. You will first want to list the timezones so that you can find yours. If you want to set timezone to UTC, you won’t find UTC there. Remember that UTC is a standard, not a timezone.

GMT is the timezone that is the same time as UTC so if that is what you are looking for you can use GMT. All the other timezones are based on UTC and adjusted for their location around the world. 

Just follow the steps below to set your timezone.

Step 1: View the List of Timezones

Use the systemsetup -listtimezones to see the list of valid timeszones you can set. 

The list is quite long so you will want to use | more at the end of the command to keep them from all scrolling through the screen. 

systemsetup -listtimezones | more

Just hit the space bar to move through the list.

Step 2: Set the time zone 

Type sudo systemsetup -settimezone [your time zone], “your time zone is the name of the time zone you choose from the list in step 1. 

We will use Denver, CO, USA for this example:

sudo systemsetup -settimezone America/Denver

Step 3: Verify the time zone has been set

Type the following command into the Terminal and hit enter to verify your time zone was correctly set. The terminal will output “Time Zone:” followed by its current time zone setting. 

sudo systemsetup -gettimezone 

FAQs

We get lots of questions about Mac settings, here are the most frequent ones related to date and time. 

Why are the date and time wrong on my Mac?

There are a number of reasons the date and time on your Mac may be wrong. In most cases, it is that you don’t have the setting enabled to automatically set the time. 

This can also happen with a Mac that does not have internet access and cannot connect to time.apple.com which sets the time.

Why won’t my Mac let me change the date and time?

To change the date and time, you must have administrative permissions on your Mac. You will also need to make sure that the setusingnetwroktime feature is turned off or you will not be able to change it.

You can check this by typing sudo sytemsetup -getusingnetworktime into the Mac Terminal. The command sudo systemsetup -setusingnetworktime off should turn it off. 

How do I change the date format on my Mac?

You can change it from your desktop by going to System Preferences and then Language & Region. From there click on the Advanced button.

You will see a Dates tab which will allow you to specify the date format you see on your desktop and other places.

Final Words

Setting the date and time from Mac Terminal is fairly simple. Just keep in mind that you need to know the password for your admin account and you need to turn off the automatic time and date setting. I hope the information above can help you to set your time and date.

As usual, please let me know if you have any questions or comments. I would love to hear from you.

If you’ve left your Mac lying around for a very long time or if you bought a used one, the system date may be out of whack. Often the system date on neglected Macs gets reset to the year 2001, which prevents you from reinstalling OS X, but you can get this done through Terminal.

UPDATE: This article is dated and may not be relevant to your version of macOS. Please use with caution and understand that whatever you do to your Mac is on you. We hold no responsibility for any damage following this guide may cause.

More often than not, you’ll get an error that reads, “An error occurred while preparing the installation. Try running again.” At this point, many people will throw in the towel and figure the computer is toast. But that’s usually not the case.

system date terminal macos

A terminal window looks similar to this.

Change System Date From Terminal

Here are some simple steps to change the OS X system date from Terminal when doing a fresh install.

  • Insert a USB key with OS X install into Mac (or install disc)
  • Power up and hold the Option key down as soon as you hear the startup chime.
  • Choose OS X to install
  • Once booted into recovery, choose Utilities from the menu and then Terminal.
  • Type date into Terminal and hit enter; this displays the date; if it is not the current date, you need to go to the next step.
  • Type date into Terminal followed by today’s date in this format [month][day][hour][minute][year] so today is July 11, 2016, 2:15 that would be date 0711141516 then press enter. Of course, your date and time will vary.
  • Rerun the first command in Terminal date and press enter; the date should now be fixed.

At this point, you should now be able to continue your reinstall of OS X on your Mac, and the installation error should no longer appear. For whatever reason, the system date matters when installing the OS on your Mac. So if you get that error, don’t panic and think your Mac is toast, try this fix first, and you should be golden.

Conclusion

This is a fairly easy fix, and it works wonders if you’ve purchased a Mac off of eBay or from Craigslist. Sometimes these Macs end up sitting around for a while, and the system date gets out of whack. Now you don’t have to worry about it being a brick and can bring it back to life.

Did you use this method to fix your system date? Let us know in the comments below or on Twitter, or on Facebook. You can also comment on our MeWe page by joining the MeWe social network.

Last Updated on December 11, 2021.

  • 2023

Mac OS X Welcome Videos

Mac OS X Welcome Videos

Оглавление:

  • Установите системную дату в Mac OS X из командной строки с центральным сервером времени
  • Установите системную дату Mac вручную с помощью команды терминала

Часы в Mac OS X устанавливаются автоматически по умолчанию, но если вы хотите установить точное время или ищете решение для командной строки, чтобы установить системное время, вы можете сделать это с помощью инструмента ntpdate или стандартной даты. команда.

Установите системную дату в Mac OS X из командной строки с центральным сервером времени

Для ntpdate, который устанавливает дату и время на основе времени с центрального сервера, доступ к которому осуществляется через Интернет, вы можете указать его либо на серверах времени Apple, либо на pool.ntp.org, чтобы получить точное время:

sudo ntpdate -u time.apple.com

При появлении запроса введите пароль администратора, и вскоре вы увидите что-то вроде следующего:

4 Jul 14:30:11 ntpdate: adjust time server 17.151.16.14 offset 0.000336 sec

Смещение в конце позволяет узнать, насколько отличались системные часы от вновь установленного времени. В этом примере системные часы были отключены на смехотворно малую долю секунды.

Как правило, вам не нужно делать это, если вы используете функцию «Установить дату и время автоматически» в системных настройках «Дата и время», хотя, устанавливая часы в командной строке, вы можете быть уверены, что на каждом компьютере в сети отображается точное в то же время.

Установите системную дату Mac вручную с помощью команды терминала

Другой подход состоит в том, чтобы установить дату вручную из командной строки, используя командную строку «date», где date в формате ЧЧ] MM, то есть месяц Date Hour Minute Year без разделения. Это выглядит примерно так:

date 0712122318

Для этого примера будет установлена ​​дата «12 июля 2018 года в 12:23».

Вы можете узнать больше об установке даты с помощью даты –help, которая также указывает, что вы можете даже установить секунды, если хотите.

Трюк с датой — это то, что вы хотели бы использовать, если у рассматриваемого Mac нет доступа в Интернет по той или иной причине.

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Как изменить датасет
  • Как изменить датапаки
  • Как изменить данные чужого сайта
  • Как изменить данные чипа собаки
  • Как изменить данные чипа на собаку

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии