0

Strike "C-u C-c ." to insert the current datetime,

  <2020-03-25 Wed 09:56>

How could I designate a accurate day of 20 days later,
Currently, I invoke "Shift+ right-arrow" step-move the the day of 20 days later.

Is it possible to insert a future day with a method of "+20d"?

1

The function org-time-stamp from the library org.el supports the increment/decrement day feature out of the box. In an org-mode buffer, type C-c . or C-u C-c . and then just type +20 and press the enter/return key. The function org-time-stamp uses the function org-read-date -- to read the various options for org-read-date, type M-x describe-function aka C-h f.


Here is an alternative method that lets the user control the format of the time/date that gets inserted -- the format is hard-coded. The function org-read-date from the library org.el supports the increment/decrement day feature out of the box. The doc-strings for org-read-date and format-time-string are lengthy, so go ahead and type M-x describe-function aka C-h f to read about the various options. To try out this example using my-org-insert-date below, type M-x my-org-insert-date and then just type +20 and press the enter key. This will work in any mode; i.e., there is no requirement that the buffer be in org-mode in order to use this example.

(require 'org)

(defun my-org-insert-date ()
"Insert a date at point using `org-read-date' with its optional argument
of TO-TIME so that the user can customize the date format more easily."
(interactive)
  (let ((time (org-read-date nil 'to-time nil "Date:  ")))
    (insert (format-time-string "<%F %a %I:%M>" time))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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