# Change \the\year

Is it possible to make LaTeX believe that the current year is 2012, so that \the\year prints 2012?

\documentclass{article}
\begin{document}
% What to do so that the following prints 2012?
\the\year
\end{document}

I haven't found advice in The \the command; trying to set \year using \setcounter{year}{2012} didn't work either.

• It's an internal variable, not a LaTeX counter: \year=2012 Jun 16 '14 at 21:54
• @egreg: Thanks for enlightening me, works like a charm but has to come after \begin{document} (not a problem for me). Care to write this as an answer? How does this fit the accepted answer of the linked question? Jun 16 '14 at 22:02
• I have supplemented my answer there with these parameters. Jun 16 '14 at 22:09

TeX initializes \day, \month, \year and \time at the beginning of a job; they are internal integer registers that can be assigned new values. However, there is no LaTeX interface for modifying their values, so the primitive TeX assignment style has to be used: thus

\year=2012

will do, and similarly for the other registers mentioned above. Leave a space (or end of line) after the value, or append \relax to be sure.

Note that \time is initialized with the number of minutes past midnight when the job started. The initial values of \day, \month and \year are the expected ones.

You can print their values by prefixing the register's name with \the, as described in The \the command.

Just for fun, without a TeX primitive:

\documentclass{article}
\begin{document}
\ThisYear{1492}      Christopher Columbus discovers America in \the\year. \par
\SetDate[20/07/1969] Man takes first steps on the Moon in \today. \par
\end{document}
• Interesting. So, the advdate package interacts with the TeX variables? Jun 17 '14 at 7:04
• @krlmlr Yes. Commands as \ThisYear are fairly simple (only do \year#1 \relax) but the package is justified because add x days to \today and obtain the right date is not so easy.
– Fran
Jun 17 '14 at 15:23

Just for fun, a quick LaTeX interface to the year:

\documentclass{article}

\makeatletter
\let\c@year\year
\makeatother
\newcommand*{\theyear}{\Roman{year}}

\setcounter{year}{2012}

\begin{document}
\theyear
\end{document}