By default display-time-mode
shows the time only in minutes. How I can display time in seconds? Something like 18:34:45"
.
The top of the EmacsWiki page on Display Time tells you how to control the format of the time.
Of the three variables, it looks like display-time-format
is the most relevant after inspecting the docstrings of the variables with C-h v display-time-format
:
String specifying format for displaying the time in the mode line. See the function
format-time-string
for an explanation of how to write this string. If this isnil
, the defaults depend ondisplay-time-day-and-date
anddisplay-time-24hr-format
.You can customize this variable.
Now, as @lawlist suggested, you can figure out how to set up the string by looking at the docstring for the function format-time-string
, although there are too many options to list here. However, you're probably interested in %I
, %M
, and %S
:
...
%H is the hour on a 24-hour clock, %I is on a 12-hour clock, %k is like %H only blank-padded, %l is like %I blank-padded.
%p is the locale's equivalent of either AM or PM.
%M is the minute.
%S is the second.
...
So you can either use the customize interface to set display-time-format
, or you can do so directly with:
(setq display-time-format "%I:%M:%S")
However, I doubt you're going to be happy with this functionality. From the Emacs manual on mode line basics:
For efficiency, Emacs does not continuously recompute each window's mode line and header line. It does so when circumstances appear to call for it—for instance, if you change the window configuration, switch buffers, narrow or widen the buffer, scroll, or modify the buffer.
In other words, you're not going to get a seconds counter in your mode line. When, after open Emacs with no init file (emacs -Q
), I enable display-time-mode
and set up the display-time-format
as above, the mode-line updates as the seconds turn over to 00
and not every second.
-
1If I understand well, your short answer is that what I have asked for is not possible to be done. By the way there is a missing % in the line
(setq display-time-format "%I:%M:S")
in your answer. – Name Jan 6 '15 at 8:37 -
1Fixed the typo, thanks. The longer answer was to give you a feel for how you might go about discovering the answer yourself. If you really wanted seconds in your mode line, you would need to force the mode line to update every second. I wouldn't be surprised if there's a way to do that, but it doesn't seem worth the effort. – Dan♦ Jan 6 '15 at 13:31
format-time-string
andmode-line-format
andemacs
– lawlist Jan 5 '15 at 23:28