I wrote a LuaLaTeX-only package named datestamp for this :)
It's pretty new, so might take 2-3 days to come in the distributions. If you are impatient you can clone the git repostiory; run l3build install in the datestamp/datestamp directory. This will install the package in your local texmf.
A short example
% !TEX TS-program = lualatex
\documentclass{article}
\usepackage{datestamp}
\begin{document}
The date I write with \verb|\adddatestamp| doesn't change.
\adddatestamp{firstds}
\end{document}
Let's say your filename is random.tex. Running the above code will generate a random.ds file. Assuming you run it today; the .ds file will have the following text.
firstds = "October 22, 2021"
This is then interpreted as a lua-code which makes firstds a variable and then the value of this variable (which is the date) is printed in TeX. As long as you preserve the .ds file; your dates won't change, but let's say you lose your .ds file by mistake; there is still no need to worry. You can fool the program by writing your own .ds file and using exactly same keys in your document as argument of \adddatestamp command.
An automated example
\documentclass{article}
\usepackage{kantlipsum}
\usepackage{datestamp}
\NewDocumentCommand{\dsfoot}{ }{%
\adddatestamp{pn\thepage}%
}
\usepackage{fancyhdr}
\pagestyle{fancy}
\cfoot{}
\rfoot{Last modified: \dsfoot}
\begin{document}
\kant
\kant
\kant
\end{document}
If you add two more \kants on some other day, those pages will show that particular date. Your .ds file will look like the following:
pn1 = "October 22, 2021"
pn2 = "October 22, 2021"
pn3 = "October 22, 2021"
pn4 = "October 22, 2021"
pn5 = "October 22, 2021"
pn6 = "October 22, 2021"
pn7 = "October 22, 2021"
As explained earlier; if you want to have a different date on let's say page number 4, you can edit the .ds file; change the value of pn4 to, say, "December 22, 2021". From the next compile; output will show December 22, 2021 only on page 4.
Note: Please be careful while using the names of the variables. It seems like Lua doesn't like only numeric variables. I haven't dug deep; but using \thepage instead of pn\thepage throws a weird Lua error. So better have alphanumeric variables like ds1, pn1.
\today, the whole document gets the date stamp at compilation time (I use stamps in this manner quite frequently). If you want each page to have a unique stamp, you will have to manually enter the date at the point of each change. That may be more trouble than you are looking for. Can you give us more context on what the content is that you are hoping to datestamp (e.g., general document text or particular tables or data blocks)? – Steven B. Segletes Aug 23 '21 at 12:23\inputto the main document then you could access the last modified file date for each section. – David Carlisle Aug 23 '21 at 13:21