So I know this question may come across a bit weird but I'm looking for a way to change what LaTeX considers the current time. (In other words what \currenttime is for LaTeX)

I'd like to have this for easily reproducible builds of LaTeX documents. I do get the correct timestamp from somewhere externally.

So I cannot permanently change the tex file itself. In the (git) repository it must remain as \currenttime.

I came up with a number of possible solutions but they all seem a bit hacky to me and so I am wondering if there's a better way to do it.
These possible solutions are:

  • Set the date and time of the build machine.
    I'm going to use Docker anyways so I could just set the time of the build container. Though that might mess with some stuff so I'm not too keen on doing that.
  • Use something like sed to replace \currenttime with the desired timestamp.
    I currently don't know what format such a timestamp needs to be in I'm sure that's trivial to google. Also I don't like that this alters the tex file itself

1 Answer 1


Recent pdfTeX, etc., recognise two environmental variables here:

  • SOURCE_DATE_EPOCH - Unix epoch value
  • FORCE_SOURCE_DATE - switch to enable use of the epoch (set to 1 or higher)

So if you set them in the environment, pdfTeX, etc., will always 'see' the same date and time.

  • Does lualatex accept these too? Or is there an alternative for lualatex?
    – BrainStone
    Nov 5, 2019 at 16:22
  • The answer to that is yes. I also misread the answer (glossed over the ", etc." part).
    – BrainStone
    Nov 5, 2019 at 17:26

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.