How to Customize Date Format Using Terminal on macOS (Bite-size Article)
Tags: terminal
Published: 2024-06-28 20:27:01

# Introduction
_Note: This article is written for Mac users._

I recently updated macOS to the latest version, **Sonoma**. With this update, I found that the default date format was changed. Usually, I prefer to use **DD/MMM/YY** format for long years, and have used it for logging work and personal projects. However, with the new OS update, I could no longer use my preferred format.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lhxxbj7h32lh4053d8zb.png)



Of course, it is very inconvenient to be able to input data manually but not be able to use keyboard shortcuts.

When the date format you use daily changes, it takes time to get used to it. In my case, I was accustomed to the format like, "16/Jun/2024", but it changed to "16/6/24" now, which I found harder to read. While the system preferences offer several date formats, none exactly matched the format I was using.

Searching on Google about this issue, I found that other Mac users were also looking for a solution in various forums. Although this is a minor change, it has impacted some users. Therefore, I wondered if it was possible to revert to the original format.

Fortunately, I found a solution, and in this article, I will introduce how to customize the date format using Terminal.

_* Please note that the following steps involve customizing the system-wide settings domain. This could lead to unexpected behavior or issues. Please proceed at your own discretion and responsibility!_


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdmknfszp7exjw8muf6e.png)



# Changing Date Format Using Terminal
In macOS, you can customize the system-wide date format using Terminal. Here are the steps to change the date format to "DD/MMM/YY".

## Step 1: Open Terminal
First, open Terminal. You can usually find Terminal in the "**Utilities**" folder within the "Applications" folder.

## Step 2: Execute the Command to Change Date Format
Enter the following command in Terminal and execute it:

```bash
defaults write NSGlobalDomain AppleICUDateFormatStrings -dict-add 2 "dd/MMM/yy"
```

Executing this command will apply the settings change.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z4ykuq684p0b0fl6j66t.png)



## Explanation of the Command
This command is used to change the default settings in macOS. Specifically, it adds a new date format to the setting domain called **NSGlobalDomain**. Here is a detailed explanation of each part of the command:

- <u>defaults write</u>: This is the basic command to change macOS settings.
- <u>NSGlobalDomain</u>: This indicates that the setting applies system-wide.
- <u>AppleICUDateFormatStrings</u>: This is the key for customizing the date format.
- <u>-dict-add 2</u>: This specifies that we are changing the "medium" date format. macOS categorizes date formats into several types. 1: Short format, 2: Medium format, 3: Long format and 4: Full format

- <u>"dd/MMM/yy"</u>: This part is the new date format. dd stands for day, MMM stands for the abbreviated month, and yy stands for the last two digits of the year.

---

By following these steps, you can customize your macOS date format to suit your preferences.

### Tip: Date Format Types
In macOS, there are several preset date formats, each tailored for different purposes and display styles. These presets are categorized as follows:

a. Short Format (1):

A simple format typically represented with only numbers.
Example: 12/31/23

b. Medium Format (2):

Contains a bit more detail than the short format but remains relatively compact.
Example: 31/Dec/23
This format is suitable for everyday use and is commonly used in many calendar apps and system date displays.

c. Long Format (3):

Includes more detailed information with the full name of the month.
Example: December 31, 2023

d. Full Format (4):

The most detailed format, including additional information like the day of the week and time.
Example: Sunday, December 31, 2023 at 11:59:59 PM

-dict-add 2 means changing the "medium" format among the date formats. This format is widely used in many everyday applications and systems, and changing it can significantly affect the appearance of date displays.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1olcnm46i05h4duk2kzx.png)



## Step 3: Restarting the System
By executing the above command, the settings should be applied. According to the resources I referred to, a restart may be required to enable the settings, although in my case, it worked without a restart.

Try using the shortcut command `cmd + shift + 1` (default) to date-stamp in a text to check if the change has been made. Additionally, you can change to other formats according to your preference (e.g., DD/MM/YYYY).

If the date format has changed as desired, it means the operation was successful!

### Tip: Risks and Disadvantages of Changing Date Formats
When changing date formats in macOS using the Terminal, there are several risks to consider. Although it is challenging to convey all potential issues, here are some key points to be aware of:

- Application Dependency: Some applications may depend on a specific date format, which could lead to operational issues if the format is changed.
- System-wide Impact: Changing the date format affects the entire system, potentially leading to unexpected behaviors or displays in the future.
- Resetting After Updates: macOS updates may reset the settings, requiring you to reconfigure them.
- Troubleshooting Challenges: Custom settings can complicate troubleshooting. If problems arise, Apple's official support or other support resources may not be able to respond appropriately.

---

Consider these points carefully before deciding to change the settings.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ge6aty5w0z6sngij579w.png)


# Conclusion
Even if the date format in macOS Sonoma has been changed, you can easily revert to the original format using the Terminal. As this is a system-wide setting change, please verify that it does not cause any issues in your environment before proceeding. If you are interested, feel free to try it out!

Thank you for reading!