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

后端 未结 5 2073
北恋
北恋 2021-02-06 23:51

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.

相关标签:
5条回答
  • 2021-02-07 00:09

    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.

    0 讨论(0)
  • 2021-02-07 00:09

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

    0 讨论(0)
  • 2021-02-07 00:18

    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).

    0 讨论(0)
  • 2021-02-07 00:21

    This can also be configured using git-config:

    git config [--global] log.date iso-local
    
    0 讨论(0)
  • 2021-02-07 00:29

    try this ..

    git log --date='short' --date=local
    
    0 讨论(0)
提交回复
热议问题