Update a field (#+LAST_MODIFIED: ) at save

I was trying to use time-stamp and had issues as well.
turns out the issue was time-stamp wasn’t searching far enough into the file.
set time-stamp-line-limit to something higher than 8 (default). I set it to 18.
also I am using last_modified and added a space between last_modified and time-stamp.
the following matches

#+last_modified: [2020-12-28 Mon 02:58:51]

on line 9.

(add-hook 'org-mode-hook (lambda ()
                             (setq-local time-stamp-active t
                                         time-stamp-line-limit 18
                                         time-stamp-start "^#\\+last_modified: [ \t]*"
                                         time-stamp-end "$"
                                         time-stamp-format "\[%Y-%m-%d %a %H:%M:%S\]")
                             (add-hook 'before-save-hook 'time-stamp nil 'local)))
1 Like