With --date=local
git log
shows dates in my (user\'s) timezone:
$ git log --date=local -3 --pretty=tformat:\'%cd %h\' --abbrev-commit
It does not seem to be possible to display %ci
(ISO time format) converted to the local user's timezone; it always displays in the committer's timezone. You could use %ct
and parse the output and reformat it with a utility like date
or some other script, or use %cd
.
It will be possible with git 2.7 (Q4 2015), which introduces -local
as an instruction.
It means that, in addition of:
--date=(relative|local|default|iso|iso-strict|rfc|short|raw)
you will also have:
--date=(relative-local|default-local|iso-local|iso-strict-local|rfc-local|short-local|raw-local)
You now can ask for any date format using the local timezone.
In your case:
git log --date=iso-local -3 --pretty=tformat:'%cd %h' --abbrev-commit
^^^^^^^^^
|____| that part is new!
See commit 99264e9, commit db7bae2, commit dc6d782, commit f3c1ba5, commit f95cecf, commit 4b1c5e1, commit 8f50d26, commit 78a8441, commit 2df4e29 (03 Sep 2015) by John Keeping (johnkeeping).
See commit add00ba, commit 547ed71 (03 Sep 2015) by Jeff King (peff).
(Merged by Junio C Hamano -- gitster -- in commit 7b09c45, 05 Oct 2015)
In particular, commit add00ba mentions:
date
: make "local
" orthogonal to date format:Most of our "
--date
" modes are about the format of the date: which items we show and in what order.
But "--date=local
" is a bit of an oddball. It means "show the date in the normal format, but using the local timezone".
The timezone we use is orthogonal to the actual format, and there is no reason we could not have "localized iso8601", etc.This patch adds a "
local
" boolean field to "struct date_mode
", and drops theDATE_LOCAL
element from thedate_mode_type
enum (it's now justDATE_NORMAL
pluslocal=1
).
The new feature is accessible to users by adding "-local
" to any date mode (e.g., "iso-local
"), and we retain "local
" as an alias for "default-local
" for backwards compatibility.