How can I typeset the date/time at compile time?

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?

-

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.

-
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).

\documentclass{article}
\usepackage{fancyhdr}
\usepackage[yyyymmdd,hhmmss]{datetime}
\pagestyle{fancy}
\rfoot{Compiled on \today\ at \currenttime}
\cfoot{}
\lfoot{Page \thepage}

\begin{document}
My great work.
\end{document}


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:

\documentclass{article}
\usepackage{fancyhdr}
\usepackage[us,12hr]{datetime} % us' makes \today behave as usual in TeX/LaTeX
\fancypagestyle{plain}{
\fancyhf{}
\rfoot{Compiled on {\ddmmyyyydate\today} at \currenttime}
\lfoot{Page \thepage}
\pagestyle{plain}

\begin{document}
My great work.
\end{document}


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)

-
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