Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving git log in YYYY-MM-DD format in local time zone

Tags:

git

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 ?

like image 248
Ganapathy Ramachandran Avatar asked Jul 28 '13 16:07

Ganapathy Ramachandran


People also ask

What date format does git use?

NOTE: In addition, the date part is accepted in the following formats: `YYYY. MM. DD`, `MM/DD/YYYY` and `DD.

Does GIT store time zones?

Git commits store both a Unix timestamp and a time zone offset for each commit.

Does git commit have timestamp?

There are actually two different timestamps recorded by Git for each commit: the author date and the commit date. When the commit is created both the timestamps are set to the current time of the machine where the commit was made.

What is the date in git log?

When you run git log , by default you will see the author date. If you want to see commit date, you can use one of the many command line options, such as --pretty=fuller . Note the (slight) difference between the author date and commit date above. The author date is my original, unedited, commit time.


2 Answers

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.

like image 169
VonC Avatar answered Sep 30 '22 14:09

VonC


This can also be configured using git-config:

git config [--global] log.date iso-local
like image 34
R.P. Pedraza Avatar answered Sep 30 '22 13:09

R.P. Pedraza