Why does latex think it's tomorrow already?

Strange problem here:

Brandon@forge ~/Dropbox/research.local/oil
$date Tue, Nov 27, 2012 6:14:23 PM Brandon@forge ~/Dropbox/research.local/oil$ cat <<EOF | pdflatex
\documentclass{article}
\begin{document}
\today
\end{document}
EOF


gives me a document whose content reads "November 28, 2012".
Now, I imagine this has something to do with locale or time zone – but why would that be different inside of TeX than at the command line?

Worth mentioning: I'm running Cygwin on Windows 7 and TeX Live 2012.

-
What does \currenttime from the datetime package give you? –  Qrrbrbirlbel Nov 28 '12 at 2:46
I'm running the same system (Cygwin, Windows 7, TeX Live 2012) and the output is as expected. You're sure you checked texput.pdf? –  Werner Nov 28 '12 at 3:00
I'm not good at these things but it's not possible to have Dropbox server time, is that right? –  percusse Nov 28 '12 at 3:13
datetime picks up the date and time from the TeX count registers \year, \month, \day and \time. TeX sets these at the start of the tex/latex run. I assume it gets the information from the operating system it's running on. What do get if you use \pdfcreationdate ? –  Nicola Talbot Dec 2 '12 at 18:36
Sorry, haven't asked you yet: what if you run pdflatex from cmd instead of through bash? Or unset TZ in bash and run from bash? –  cyberSingularity Dec 17 '12 at 22:28

As soon as you mentioned the TZ environment variable, it seemed like the likely culprit, especially as you are running the Windows version of TeX Live rather than the cygwin version (which is a perfectly reasonable thing to do, so hopefully this is the only issue it causes). I believe Windows and cygwin have different interpretations of that variable, and when running Windows binaries from cygwin sessions, the cygwin environment is inherited. Presumably outside of cygwin on your system, the TZ variable is not set.

So, to ensure the time is correctly interpreted, you need to unset the TZ variable before using native Windows binaries such as the TeX Live binaries. To avoid globally unsetting the variable (which surely serves other needed purposes in cygwin), perhaps consider the use of bash aliases, eg alias pdflatex="TZ= pdflatex".

To attempt to answer your latter question from the comment about which TZ value to use in cygwin, the official time zone database has the following text before the America/Los Angeles entry:

# US Pacific time, represented by Los Angeles
#
# California, northern Idaho (Benewah, Bonner, Boundary, Clearwater,
# Idaho, Kootenai, Latah, Lewis, Nez Perce, and Shoshone counties,
# and the northern three-quarters of Idaho county),
# most of Nevada, most of Oregon, and Washington

-
Thanks for the discussion and the solution. I added an 'unset TZ' into my workflow. –  Brandon Kuczenski Dec 17 '12 at 23:43