28

To get YYYY-MM-DD format for dates git log --date=iso is used. To force dates in your local time zonegit log --date=local is used.

I was trying to combine both the options but it was a failure. So is there a way (git log command) to get date (YYYY-MM-DD format) in my local time zone ?

Sergey K.
  • 24,894
  • 13
  • 106
  • 174
  • It is a bit of an odd question because ISO format includes a timezone specifier... – nneonneo Jul 28 '13 at 16:36
  • 1
    possible duplicate of [git: timezone and timestamp format](http://stackoverflow.com/questions/7651644/git-timezone-and-timestamp-format) – Sergey K. Jul 28 '13 at 16:39
  • I found an archive of same question in GIT http://git.661346.n2.nabble.com/orthogonal-cases-of-log-date-option-td2414018.html I'm not sure what was concluded... – Ganapathy Ramachandran Jul 28 '13 at 16:56
  • With git 2.7 (Q4 2015), you will be able to use `git log --date=iso-local`. See [my answer below](http://stackoverflow.com/a/32990722/6309) – VonC Oct 07 '15 at 11:14

5 Answers5

25

With git 2.7, use:

git log  --date=iso-local

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.


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)

See git log date format for more.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for sharing. That looks promising but not satisfying. Where is the point stil adding the tz offset if all times are in your local timezone? This is just pollution. I have added [my comment](https://github.com/git/git/commit/7b09c459d346d9bf30ab07921a9b0ee91405d104#commitcomment-13636084) ot the merge. – Michael-O Oct 07 '15 at 11:28
  • @Michael-O this is orthogonal to the date format. The format does not change. Its ability to use the local timezone does. – VonC Oct 07 '15 at 11:32
  • I understand but this is half-breed to me. – Michael-O Oct 07 '15 at 11:35
10

This can also be configured using git-config:

git config [--global] log.date iso-local
R.P. Pedraza
  • 173
  • 1
  • 6
0

see this answer (since Git v2.6.0-rc0) and this answer (hack for older versions)

Community
  • 1
  • 1
radistao
  • 14,889
  • 11
  • 66
  • 92
0

A lot of time passed since the question, but this link was one of the first in google, and it had no answer.

So for people who find it: what you want is --date=format-local:'%F' (or %F %R for time too).

Ilya Kantor
  • 581
  • 5
  • 11
-2

try this ..

git log --date='short' --date=local
Sukhmeet Singh
  • 303
  • 2
  • 14