I'm currently using \isodate{\today} \currenttime} to include an aproximate creation time for a XeTeX document. This is "good enough" but doesn't include the timezone. In pdflatex the creation time of a document can be included with \pdfcreationdate, is there an equivalent command that works with XeTeX?


This can be done by running an external program, for example, date on Unix systems. The output can be redirected to a file and then read by TeX. On Unix systems, also piping is possible.



\immediate\write18{date >\jobname.date}

Current time is: \input{\jobname.date}


The shell escape feature can be enabled by command line option -shell-escape (TeX Live) or --enable-write18 (MiKTeX).

| improve this answer | |
  • For Windows users, use \immediate\write18{date /t >\jobname.date}. – Friendly Ghost May 21 '15 at 10:11
  • Thanks. However, I'm converting documents with pandoc (which doesn't yet have support for --latex-engine-opt) so was hoping to avoid anything that needs specific flags. – zzkt May 21 '15 at 10:33
  • @nikgaffney In my answer I have listed the officially documented option names. They work regardless of the compiler (also in TeX, pdfTeX, LuaTeX). Nowadays, TL15 and MiKTeX seems to support each other option names: --enable-write18 and --shell-escape can both be used. – Heiko Oberdiek May 21 '15 at 10:51
  • 1
    @nikgaffney Without the shell escape feature, the time resolution is date and time in minutes (\time) without time zone in XeTeX. But you can modify your build process to run the date command just before the pandoc command to generate the file with the full date inclusive time zone. – Heiko Oberdiek May 21 '15 at 10:54

Maybe you can use features provided by your editor. In case of emacs, you can use time-stamp. First, you have to adjust the variables time-stamp-format and time-stamp-pattern. I suggest using file local versions by putting something like this at the end of your document:

%%% Local Variables: 
%%% mode: latex
%%% eval: (set (make-local-variable 'time-stamp-format) "%3a %02d/%02m/%4y %02H:%02M:%02S %Z")
%%% eval: (set (make-local-variable 'time-stamp-pattern) "\\\\newcommand{\\\\timestamp}{%%}")
%%% TeX-master: t
%%% End: 

Next, you put the following in the first line of your document:


followed by the rest of your LaTeX code. Each time you save your document, emacs automatically updates the argument of \timestamp and you can use the command in your document, e.g.:

\newcommand{\timestamp}{Don 21/05/2015 23:05:25 Mitteleuropäische Sommerzeit}

\texttt{Last saved: \timestamp}

is the result on my box.

| improve this answer | |
  • Thanks. it's a nice idea, but i was hoping to find something built in. The --shell-escape method or modifying the build process (as mentioned by @heiko-oberdiek above) fit a little better with the automated process i'm currently working with. – zzkt May 22 '15 at 8:40

There seems to be a package Datetime. This seems to print the time zone too. Using the command \DTMnow

Refer to http://ctan.org/pkg/datetime2

| improve this answer | |
  • 3
    Your answer would be greatly improved if you provided a full working example, starting with \documentclass, which shows your point. – Steven B. Segletes May 21 '15 at 11:05
  • 2
    The package datetime2 supports seconds and time zone in case of pdfTeX, because pdfTeX provides this information in \pdfcreationdate. In case of XeTeX the package only provides the date and the time without seconds and time zone. – Heiko Oberdiek May 21 '15 at 21:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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