2

I want the timestamp <2017-07-26 Wed> in my org document to be exported to html as Wed 26-July '17. Is this customization possible?

More generally, is it possible to customize how timestamps are exported to various formats, such as latex, ascii, etc?

Issuing M-x org-version yields Org mode version 9.0.9 on my system.

2
  • I found the variable org-html-metadata-timestamp-format in ox-html. Seems like customizing it would have an effect on how timestamps are displayed. For the record, I was looking through source code of org-mode 8.3.3. The easiest way to look for these would be to <kbd>M-x customize-group</kbd> and pass it a group name such as org-export-html.
    – user12563
    Commented Jul 26, 2017 at 20:52
  • That would only change the format of time stamps in the preamble and the like. It would not affect time stamps in the document itself. See my answer for a more general solution.
    – deprecated
    Commented Jul 26, 2017 at 22:46

1 Answer 1

3

If you want the same time stamp format in all export formats, then you could use org-time-stamp-custom-formats. For instance, in your case you might want something like

(setq org-time-stamp-custom-formats '("<%a %d-%B '%y>" . "<%-l:%M %p, %a %d-%B '%y>"))

This won't do anything on its own. You also need to set the variable org-display-custom-times, which can be toggled on/off with C-c C-x C-t. When it is toggled on, there are two effects:

  1. Text overlays are used in the Org buffer so that a date such as <2017-07-26 Wed> will appear as <Wed 26-July '17>. (Note that the actual time stamps in the buffer are not changed, since Org requires these to be in a standard format.)
  2. The same format is used when exporting to HTML, latex, etc.

If you only want effect 2, without effect 1, then you could temporarily turn on the custom format in the export hook. For example:

(defun my-org-export-ensure-custom-times (backend)
  (setq-local org-display-custom-times t))
(add-hook 'org-export-before-processing-hook 'my-org-export-ensure-custom-times)

If desired, this could be easily extended to choose different time stamp formats according to the export backend.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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