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:

  • 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 PreferencesExample
Date & Time
Display
String for
DateFormat
Key
Time OptionsDate Options
Display the time with secondsUse a
24-hour
clock
Show AM/PMShow
the day
of the
week
Show
date
Thu 18 Aug 23:46:18EEE d MMM HH:mm:ss
Thu 23:46:18EEE HH:mm:ss
18 Aug 23:46:18d MMM HH:mm:ss
23:46:18HH:mm:ss
Thu 18 Aug 11:46:18 pmEEE d MMM h:mm:ss a
Thu 11:46:18 pmEEE h:mm:ss a
18 Aug 11:46:18 pmd MMM h:mm:ss a
11:46:18 pmh:mm:ss a
Thu 18 Aug 11:46:18EEE d MMM h:mm:ss
Thu 11:46:18EEE h:mm:ss
18 Aug 11:46:18d MMM h:mm:ss
11:46:18h:mm:ss
Thu 18 Aug 23:46EEE d MMM HH:mm
Thu 23:46EEE HH:mm
18 Aug 23:46d MMM HH:mm
23:46HH:mm
Thu 18 Aug 11:46 pmEEE d MMM h:mm a
Thu 11:46 pmEEE h:mm a
18 Aug 11:46 pmd MMM h:mm a
11:46 pmh:mm a
Thu 18 Aug 11:46EEE d MMM h:mm
Thu 11:46EEE h:mm
18 Aug 11:46d MMM h:mm
11:46h:mm

 

 

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.

Add comment

Steve

Recent Comments

Recent Posts

Archives