Elisp: Print Date Time
ISO date-time format
yyyy-mm-dd
(format-time-string "%F") ;; "2026-02-26" ;; or (format-time-string "%Y-%m-%d") ;; "2026-02-26"
ISO 8601 Format Extended
;; local time ;; no time zone (format-time-string "%FT%T") "2026-02-26T14:41:34" ;; local time ;; with time zone ;; sans colon in time zone (format-time-string "%FT%T%z") ;; "2026-02-26T14:46:06-0800" ;; local time ;; with time zone ;; with colon in time zone (concat (format-time-string "%Y-%m-%dT%T") ((lambda (x) (concat (substring x 0 3) ":" (substring x 3 5))) (format-time-string "%z"))) ;; "2026-02-26T14:46:13-08:00"
;; UTC. ;; with time zone of Z (format-time-string "%FT%TZ" nil t) ;; "2026-02-26T22:50:12Z" ;; UTC. ;; with milliseconds. ;; with time zone of Z (format-time-string "%FT%T.%3NZ" nil t) ;; "2026-02-26T22:51:36.221Z"
Common computer format
(format-time-string "%Y%m%d_%H%M%S") ;; "20260226_130818"
Unix Time Format
(number of seconds since .)
;; unix time (format-time-string "%s") ; "1291104066"
Names for Month and Week
;; full month name (format-time-string "%B") ; "November" ;; abbreviated month name (format-time-string "%b") ; "Nov"
;; full week name (format-time-string "%A") ; "Tuesday" ;; abbreviated week name (format-time-string "%a") ; "Tue"
Ordinal Date Format
format-time-string also supports ordinal date format. For example:
- “2010 January 1st” = “2010-001”
- “2010 December 31” = “2010-365”
(format-time-string "%Y-%j") ; "2010-334" for 2010-11-30