git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Wrong time in git-log when using right/ timezone

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jul 18, 2007, 18:19 UTC
Message-ID
<alpine.LFD.0.999.0707181106280.27353@woody.linux-foundation.org>
In-Reply-To
<Pine.LNX.4.64.0707181849060.1544@reaper.quantumfyre.co.uk>
On Wed, 18 Jul 2007, Julian Phillips wrote:
> 
> Is git working internally in TZ=UTC?
Yes.

The TZ in git terms has no meaning what-so-ever, it's purely for "decoration", so that people can see what the local time was. But a git time really *is* the UTC seconds-since-1970, and the timezone is saved so that it can be shown, but not for anything else.

So git always stores times in UTC, but then when showing them, it shows them as relative to the timezone they were done in.

You can see this by doing
	git cat-file commit HEAD
which shows something like
	author Junio C Hamano <gitster@pobox.com> 1184542877 -0700

and that "1184542877" is literally the time in UTC, and is the only thing that git really tracks. The "-0700" is informational, so that when you show it as a log entry, it shows as

	Author: Junio C Hamano <gitster@pobox.com>
	Date:   Sun Jul 15 16:41:17 2007 -0700
even though that "1184542877" really means "Sun Jul 15 23:41:17 2007".

So git never actually saves anything at all in local time, it just tries to show things in whatever the local time was for the person who did something (unless you use the "--date=local" option, in which case it ignores the saved TZ, and uses your _current_ TZ to show the date)

Unless we have a bug, of course.
			Linus
Previous: Julian PhillipsNext: Alex Riesen
Message 5 of 8 in “Wrong time in git-log when using right/ timezone”
  1. Peter HartlichJul 18, 2007
  2. Peter HartlichJul 18, 2007
  3. Linus TorvaldsJul 18, 2007
  4. Julian PhillipsJul 18, 2007
  5. Linus TorvaldsJul 18, 2007
  6. Alex RiesenJul 18, 2007
  7. Junio C HamanoJul 18, 2007
  8. Jan HudecJul 25, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.