TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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


Looking to include the current date, time, and timezone within a PDF.


The datetime package does not provide a macro for the current timezone.


How would you write a macro in LaTeX to create a date such as:

Sun Jan 09 20:17:18 EST 2011


Thus far:

\shortmonthname{} \twodigit{\day} \hhmmsstime{}
EST \number\year

The timezone (EST) eludes me.


Thank you!

share|improve this question
up vote 15 down vote accepted

You can get the offset from GMT using the pdfTeX primitive \pdfcreationdate: (no doubt LuaTeX has something similar)

\def\grabtimezone #1#2#3#4#5#6#7#8#9{\grabtimezoneB}
\def\grabtimezoneB #1#2#3#4#5#6#7{\grabtimezoneC}
\def\grabtimezoneC #1#2'#3'{sign: #1 / hr: #2 / min: #3}
\expandafter \grabtimezone\pdfcreationdate

If you need to convert this into a timezone string, you'll need to define a dictionary of timezones to match up with the time offsets. Since I think this is a many-to-one mapping for many time zones, I'm not sure how that would work.

Once you work out exactly what you need for your application, I suggest writing to the datetime author to add such a feature to that package.

Update. To get a crude lookup table for getting string output for the timezone, you can try something like this:

\@namedef{timezone+1030}{CST'}% daylight savings
\def\grabtimezone #1#2#3#4#5#6#7#8#9{\grabtimezoneB}
\def\grabtimezoneB #1#2#3#4#5#6#7{\grabtimezoneC}
\def\grabtimezoneC #1#2'#3'{%
    {No timezone for `#1#2#3'}

share|improve this answer
will not work if you are minus UTC time i.e., plus sign needs to be -! – Yiannis Lazarides Jan 10 '11 at 7:54
@Yiannis good point. thanks; I've updated the answer. – Will Robertson Jan 10 '11 at 8:06
excellent solution! – Yiannis Lazarides Jan 10 '11 at 8:10

There is now the filemod package which can return the file modification date of any file (which can be found by TeX). It is based on the \pdffilemoddate macro. It works with pdf(La)TeX and Lua(La)TeX, but not with Xe(La)TeX.

If you want the time when the main file was last changed use \jobname as filename in the macros below. If you really want the compile time you can use the macros with a trick:


and then keep the {<filename>} argument empty.

You can print, i.e. typeset the date, time and timezone using


Only the date or time+timezone are printed with


They use the \thefilemoddate and \thefilemodtime to format the result. These macro get {<YYYY>}{<MM>}{<DD>} or {<HH>}{<mm>}{<SS>}{<TZ>} as arguments, respectively. You can redefine these to print the date or time in a custom format. There is also \thefilemod for \filemodprint which gets all seven arguments and by default calls the other two macros.

You can also create your own macro with seven arguments and use:


Then the timezone would be #7.

share|improve this answer

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.