[Tex/LaTex] Is it possible to make LaTeX retrieve date information from system clock


Well, this question is pretty weird 😉 I know TeX is strictly sandboxed, but I guess there is at least some possibility? After all, system clock (for instance, UNIX time on UNIX-like systems) is only 8 bytes or so in memory.

I would be very impressed if retrieving date information in LaTeX is actually possible! 😀 That way I would be able to create such a template that I do not need to adjust the date of each new article…

Best Answer

You mean something like that

cat wr.tex
\immediate\write18{date > date.tex}

latex -enable-write18 wr.tex


If you don't need time but need only date, there are counters like \year, \month and \day.

To put current year in text say \number\year, to put month number use same construction. To put month name there must be a construction in your babel file like \today (puts today's date to document) or you can make construction like

\def\monthname{\ifcase\month\or January\or February\or March … \fi}

Then macro \monthname will write current month' name to the document.