TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For printed drafts of my papers, I would like to add a timestamp on every page with the date/time when the document was last compiled. Is there any LaTeX command that produces the current date/time at compile time? Even better, is there any package that already solves my problem?

share|improve this question
up vote 49 down vote accepted

One can use \today to get the current date, the command \currenttime from datetime package to get the current time, and fancyhdr package to add it to every page.

share|improve this answer
Is there a version of \currenttime which comes from a standard class? I'm not sure if people have installed that package. I'll share my file. – Sigur Nov 28 '13 at 0:06

Expanding on Grigory's answer, here's a MWE. To get the date and time in a reasonable format, I found that I wanted the most recent version of datetime, which is dated 2010/02/06 (the version that is on my system - from TeXLive 2009 - is dated 2007). Using the default options for date and time format made the information too long (as it is, I decided it was better to shift the page number from the centre to the left).

\rfoot{Compiled on \today\ at \currenttime}
\lfoot{Page \thepage}

My great work.

If for some reason you can't use the 2010 version (or can't be sure that coworkers have it), a solution that works on the older datetime is as follows:

\usepackage[us,12hr]{datetime} % `us' makes \today behave as usual in TeX/LaTeX
\rfoot{Compiled on {\ddmmyyyydate\today} at \currenttime}
\lfoot{Page \thepage}

My great work.

This later version also keeps the pagestyle closer to the plain default, you can edit of course as you like. The date will also show as "ddmmyyyy" instead of "yyyymmdd" but that's probably fine for your needs.

(edited by Andrew in response to Juan's comment - I can't resist a challenge; and then edited again by Juan to improve the example)

share|improve this answer
Thanks for the answer and example. It's a shame, though, that the version of datetime on TeX Live is outdated, as I can't reliably expect collaborators to also have the latest version. I'll have to hack my way through the older datetime. – Juan A. Navarro Aug 4 '10 at 11:01
Thanks for the update! Hope you don't mind I cleaned up a bit your example for the older datetime so that it's less hackish. ;) – Juan A. Navarro Aug 4 '10 at 11:56
@Juan A. Navarro: I guess I do have a bit of a tendency to go straight for the hack! \makeatletter is a bit of a give-away. I'll add here (rather than editing yet again) that, for this case, the obvious advantages of the newer version of datetime are: more formats and \currenttime includes seconds. – Loop Space Aug 4 '10 at 12:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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