Setting the Date and Time Format for the macOS Menu Bar Clock Using Terminal

S

In the Clock tab of the Date & Time pane of System Preferences you can choose between displaying a digital or analog clock in the menu bar. For a digital clock there are five options that determine how the date and time are displayed:

UPDATE 2020-11-15: These instructions are for versions of macOS up to and including Catalina 10.15. If you have macOS Big Sur 11.0 installed please use the menu-bar-clock.sh shell script to set the date and time format of the menu bar clock from the command line.
  • Display the time with seconds
  • Use a 24-hour clock
  • Show AM/PM
  • Show the day of the week
  • Show date

There is a sixth option: Flash the time separators, which I’ve not included as I don’t consider this to be part of the date and time format.

Date & Time pane of System Preferences showing the Clock tab
Date & Time pane of System Preferences showing the Clock tab

 

 

These options can also be configured from the command line using the defaults command to edit the ~/Library/Preferences/com.apple.menuextra.clock.plist configuration file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>DateFormat</key>
    <string>EEE d MMM HH:mm</string>
    <key>FlashDateSeparators</key>
    <false/>
    <key>IsAnalog</key>
    <false/>
</dict>
</plist>

 

 

The date format has no affect with an analogue clock. So firstly, to ensure a digital clock is displayed, set the value of the IsAnalog key to false. In Terminal type:

Dummy Content
defaults write com.apple.menuextra.clock IsAnalog -bool false

 

 

The value of the DateFormat key is a string which determines how the date and time are displayed. To set the date and time format to display Thu 18 Aug 23:46, in Terminal type:

Dummy Content
defaults write com.apple.menuextra.clock DateFormat -string "EEE d MMM HH:mm"

 

 

The table below details all the possible valid combinations of the five date and time format options in System Preferences together with an example of how the date and time are displayed for each and the corresponding string value for the DateFormat key. Note that Use a 24-hour clock and Show AM/PM are mutually exclusive options.

System Preferences Example
Date & Time
Display
String Value for
DateFormat
Key
Time Options Date Options
Display the time with seconds Use a
24-hour
clock
Show AM/PM Show
the day
of the
week
Show
date
Thu 18 Aug 23:46:18 EEE d MMM HH:mm:ss
Thu 23:46:18 EEE HH:mm:ss
18 Aug 23:46:18 d MMM HH:mm:ss
23:46:18 HH:mm:ss
Thu 18 Aug 11:46:18 pm EEE d MMM h:mm:ss a
Thu 11:46:18 pm EEE h:mm:ss a
18 Aug 11:46:18 pm d MMM h:mm:ss a
11:46:18 pm h:mm:ss a
Thu 18 Aug 11:46:18 EEE d MMM h:mm:ss
Thu 11:46:18 EEE h:mm:ss
18 Aug 11:46:18 d MMM h:mm:ss
11:46:18 h:mm:ss
Thu 18 Aug 23:46 EEE d MMM HH:mm
Thu 23:46 EEE HH:mm
18 Aug 23:46 d MMM HH:mm
23:46 HH:mm
Thu 18 Aug 11:46 pm EEE d MMM h:mm a
Thu 11:46 pm EEE h:mm a
18 Aug 11:46 pm d MMM h:mm a
11:46 pm h:mm a
Thu 18 Aug 11:46 EEE d MMM h:mm
Thu 11:46 EEE h:mm
18 Aug 11:46 d MMM h:mm
11:46 h:mm

 

 

The full list of examples are here.

To force the menu bar to reflect any changes made to the date and time format the process that controls the display of menu bar items – SystemUIServer – needs to be restarted. In Terminal type:

Dummy Content
killall SystemUIServer

 

 

Setting the date and time format and restarting the SystemUIServer process can be combined into a single command. In Terminal type:

Dummy Content
defaults write com.apple.menuextra.clock DateFormat -string "EEE d MMM HH:mm" && killall SystemUIServer

 

 

Finally, to flash the time separators in the time and date display set the value of the FlashDateSeparators key to true. In Terminal type:

Dummy Content
defaults write com.apple.menuextra.clock FlashDateSeparators -bool true && killall SystemUIServer

 

 

About the author

A native Brit exiled in Japan, Steve spends too much of his time struggling with the Japanese language, dreaming of fish & chips and writing the occasional blog post he hopes others will find helpful.

14 responses

14 Comments

  • I’m running Mac OS Big Sur 11.0.1 and all menu items are black except for Menu Bar clock’s, which are white — making for an glaring contrast, and somewhat difficult to read. This happens regardless of whether the Light or Dark Appearance theme is used. Fortunately, there’s a new feature to automatically hide the menu bar so I don’t have to stare at it all the time.

  • Thank you for the Terminal command for setting the clock format! I use it to turn the clock into analog so it functions as a “Notification Center” button again, since Big Sur removed it. I use iStat Menus to provide the clock functionality too, as well as extra features like showing timezones when I click on it.
    [Imgur](https://i.imgur.com/i14YWzh.png)

  • Thank you soo much!!! I had changed the settings to use 24-hour time to try it out, only when I went back into System Preferences to change it back, for some reason, the settings were grayed out. So I’m really glad the terminal command worked, thank you!!

  • Thank you for a super helpful article.

    I have been using

    defaults write com.apple.menuextra.clock DateFormat “EEE MMM d h:mm:ss a”

    but I would like to add a literal ‘@‘ sign between the ‘d’ and the ‘h:mm:ss’ – however, nothing I seem to try will work.

    I’ve tried things like

    defaults write com.apple.menuextra.clock DateFormat “EEE MMM d \@ h:mm:ss a”

    defaults write com.apple.menuextra.clock DateFormat “EEE MMM d ‘@’ h:mm:ss a”

    but the ‘@‘ just seems to be ignored.

    Do you know if there’s a way to do this?

    Thanks!

    • @TJ Luoma

      Unfortunately I don’t. I did try your examples and interestingly the string is added to the file com.apple.menuextra.clock.plist as is, but only temporarily. As part of some integrity check – perhaps performed by the SystemUIServer process restarting – the offending characters are removed from the DateFormat string.

      Regards, Steve.

  • Thanks for the wonderful article. Is there any way to display the Year in the Menu Bar? The Character Strings now looks like EEE D MMM HH:mm:ss. Any method to look it like EEE D MMM YYYY HH:mm:ss?

    • @Siddharth,

      Not that I’m aware of, but clicking the date in the menu bar does provide a drop-down showing the year.

      Regards, Steve.

    • @Vinayak,

      It’s working for me with Catalina. Remember, changes don’t take affect until the SystemUIServer process is restarted with killall SystemUIServer.

      Regards, Steve.

Steve

Recent Comments

Recent Posts