0

I am writing a function that includes the formatted timestamp that is produced by the prompt from org-time-stamp. However, calling the function cause it to insert the timestamp into the buffer.

Is there any other similar function which produces the same calendar prompt as org-time-stamp that I can utilize for my function?

Tian
  • 288
  • 1
  • 8

1 Answers1

2

There is no such function: org-time-stamp is "sui generis".

The best thing to do is to define a new function that calls org-time-stamp in the context of a temporary buffer and then returns the string that is inserted into that buffer:

(defun my/org-time-stamp-string ()
   (with-temp-buffer
      (org-mode)
      (org-time-stamp nil nil)
      (buffer-substring (point-min) (point-max))))

Then you can call it like this:

(setq ts (my/org-time-stamp-string))

to store the string in ts and then do whatever you want with it.

For a different example of the same technique, see another recent answer of mine.

NickD
  • 27,023
  • 3
  • 23
  • 42