In this question, the OP is asking how to insert an inactive org-mode
timestamp which is (almost) what I want. One of the responders (@xji) noted that the function org-time-stamp-inactive
would insert the inactive timestamp. What I'm trying to do is to use an inactive timestamp in a property like this:
(defun add-property-with-date-captured ()
"Add DATE_CAPTURED property to the current item."
(interactive)
(org-set-property "CREATED" (org-time-stamp-inactive))
)
However, that function is interactive, I just want it to insert the current date/time. I tried passing with two universal prefix arguments:
(org-set-property "CREATED" (org-time-stamp-inactive '(16)))
It's not interactive but it inserts it twice.
In response to that, to "capture" the results of the function I tried using the approach suggested by @erikstokes in this answer:
(defun add-property-with-date-captured ()
"Add DATE_CAPTURED property to the current item."
(interactive)
(let ((inactivets (org-insert-time-stamp nil t t ))
(org-set-property "CREATED" inactivets)
)
)
but I still get an extra entry as described the OP of that question.
Currently I am using this as @kgo suggested in the same question:
(defun add-property-with-date-captured ()
"Add DATE_CAPTURED property to the current item."
(interactive)
(org-set-property "CREATED" (format-time-string "[%Y-%m-%d %a %H:%M]"))
)
It works fine but now I'm just wondering why the method described by @erikstokes didn't work for me.
Can someone suggest how I can do this using the built-in org-time-stamp-inactive
function?
with-temp-buffer
solution does.