Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I'm looking for the command to change from 12h to 24h. Is there even such a command? I mean I can do it with the GUI but I need to be able to do it via terminal so I can put it in a bash script.

Here I want instead of the 12h format a 24h format.

share|improve this question
Do you mean to convert a given time? Or alter your system time display preference? Or something else? – Andrew Ferrier Dec 17 '12 at 9:34
I want to alter my system time display preference (so the time display at the top right). I'll add this to make my question clearer. – Philipp Dec 17 '12 at 10:17
up vote 6 down vote accepted

This is stored in the plist located at ~/Library/Preferences/ under the key DateFormat.

Here's a quick primer:

  • 12 Hour Mode with AM/PM:

    EEE MMM d h:mm:ss a

  • 12 Hour Mode without AM/PM:

    EEE MMM d h:mm:ss

  • 24 Hour Mode:

    EEE MMM d H:mm:ss

To apply any of these formatting strings, you can either use the defaults command at the Terminal, or if you're looking for a more programmable method, you can use the do shell script1 directive within Applescript.

To apply these via the Terminal, open it up and run the following command:

defaults write DateFormat -string 'EEE MMM d  H:mm:ss'

Substitute the string between the quotes with the version from above that you want.

The changes don't take effect immediately after running the command, I know you can logout/log back in for the change to be made, but I'm not aware of how to apply it immediately.

1 CyberCiti Primer on Shell Scripting via Applescript

share|improve this answer
Beautiful, works like a charm. Thank you! – Philipp Dec 17 '12 at 12:28
Doesn't work for me on Yosemite 10.10.3. After I log off and log on again, the DateFormat is reset. – shrx Jun 6 '15 at 8:19
So it does work for you, it just doesn't persist. – Jason Salaz Jun 8 '15 at 0:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.