Emacs: Insert Date Time 📜
Here's a command to insert current date time.
(defun xah-insert-date () "Insert current date time. Insert date in this format: yyyy-mm-dd. If `universal-argument' is called first, prompt for a format to use. If there is selection, delete it first. URL `http://xahlee.info/emacs/emacs/elisp_insert-date-time.html' Created: 2013-05-10 Version: 2025-09-04" (interactive) (let (xmenu xstyle) (setq xmenu (list (concat "ISO date⚫" (format-time-string "%Y-%m-%d")) (concat "dotted version⚫" (format-time-string "%Y.%m.%d")) (concat "coder⚫" (format-time-string "%Y-%m-%d_%H%M%S")) (concat "all digits⚫" (format-time-string "%Y%m%d%H%M%S")) (concat "unix seconds⚫" (number-to-string (car (let ((current-time-list nil)) (current-time))))) ;; (concat "ISO full⚫" (format-time-string "%Y-%m-%dT%T") (funcall (lambda (xx) (format "%s:%s" (substring xx 0 3) (substring xx 3 5))) (format-time-string "%z"))) (concat "ISO full⚫" (format-time-string "%FT%T%z")) (concat "ISO + weekday⚫" (format-time-string "%Y-%m-%d %A")) (concat "USA + weekday⚫" (format-time-string "%A, %B %d, %Y")) (concat "USA + weekday abbrev⚫" (format-time-string "%a, %b %d, %Y")) (concat "USA⚫" (format-time-string "%B %d, %Y")) (concat "USA abbrev⚫" (format-time-string "%b %d, %Y")))) (setq xstyle (if current-prefix-arg (let ((completion-ignore-case t)) (completing-read "Style:" xmenu nil t)) (car xmenu))) (when (region-active-p) (delete-region (region-beginning) (region-end))) (insert (nth 1 (split-string xstyle "⚫")))))