Print Current Date and Time in Emacs Minibuffer

I don’t show a clock on my computer. Sometimes, I quickly want to find out what time it is, though. I often run date from the shell to get the current time, and can often get there in my Quake console-like iTerm 2 Hotkey Window by pressing the “up” key since I seldom use the Hotkey Window for anything else.

That’s all nice and dandy, but when I work in emacs anyway, I could show the time there with a shortcut, too, right?

Apparently, there’s only (display-time 1) built-in that shows a clock in the modeline. This is just like showing a clock in the Mac menu bar. Don’t want it. I just want a quick glance at the current time a couple of times throughout the day.

So I wrote my own function for this, thanks to ErgoEmacs being the only resource that popped up when I searched for instructions on how to print/echo/message the current time.

(defun display-current-time ()
  (interactive)
  (message (format-time-string "%Y-%m-%d %H:%M:%S")))

Of course there’s stuff like a full-screen live SVG analog clock. That’s fun, but not so useful to quickly now the time of day. I guess that task is too trivial for most emacs folks to bother, or they just stick to the permanent system clock.

I also like the built-in calendar (see an example calendar display) because it’s easy to get to and quit it again. It sports hotkeys for lunar phases, shows diary entries and appointments, can display sunrise and sunset times for my current location, and all sorts of other things – but does not come with a simple ticking clock. Go figure. Not even the visual, iCal-like calendar framework project does this.