I usually use Spacemacs in maximized window, thus the date and time presented in mode line is a must.

I understand that spacemacs uses powerline mode to mimic vim, the manuals of both spacemacs and powerline does not tell how to add new section to display additional info (in this case it is date and time).

I have attempted to comprehend the nyan cat code in color layer, but my elisp skill did not satisfy.

4 Answers 4


To get the time mode, just add (display-time-mode 1) to your ~/.spacemacs configuration.

To get date and time, do this instead

;;display time in powerline
  (spacemacs|define-mode-line-segment date-time-segment
    (shell-command-to-string "echo -n $(date +%k:%M--%m-%d)")
  (add-to-list 'spacemacs-mode-line-right 'date-time-segment)

Source: https://www.reddit.com/r/emacs/comments/3lu414/how_to_add_date_and_time_into_spacemacs_powerline/

I customized mine with this...

  ;; display time in powerline
  (spacemacs|define-mode-line-segment date-time-segment
    (shell-command-to-string "echo -n \"⏰  $(date '+%a %d %b %I:%M%p')\""))
  (add-to-list 'spacemacs-mode-line-right 'date-time-segment)

so now my powerline looks like this


  • 1
    As far as I can tell, this solution is out of date. See my answer for what worked for me.
    – Dave
    Commented Feb 25, 2018 at 17:56

What worked for me was the following.

(spaceline-define-segment datetime
  (shell-command-to-string "echo -n $(date '+%a %d %b %I:%M%p')"))
(spaceline-spacemacs-theme 'datetime)

I had to put that code in user-config section of .spacemacs.


Mine's working great just with:

(setq display-time-format "%H:%M:%S %a,%d %b %Y")

  • Welcome to Emacs.SE! Could you please elaborate on what, if anything, the OP has to do to incorporate your code into his spacemacs configuration. It would also help if you could explain how your answer differs from the others already posted.
    – Dan
    Commented Mar 25, 2020 at 15:26

Emacs has native time functions: current-time-string and format-time-string. You should just have to eval one of those - i.e. (current-time-string). This works fine for telephone line, so I would assume it's the same for powerline/spaceline/etc.


(spaceline-define-segment datetime
(spaceline-spacemacs-theme 'datetime)

Here's the doc for format-time-string if you want something other than the default:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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