Git 2.6(2015年第3季度)添加一个新选项。
介绍“格式”日期模式
This feeds the format directly to strftime.
Besides being a little more flexible, the main advantage is that your system
strftime may know more about your locale’s preferred format (e.g., how to spell the days of the week).
--date=format:...
feeds the format ... to your system strftime.
Use --date=format:%c to show the date in your system locale’s preferred format.
See the strftime manual for a complete list of format placeholders.
原始答案(2014年中期)
–date选项(在2009年12月的commit 02b47cd中为git1.7.0引入)使用与GIT_AUTHOR_DATE相同的格式,日期格式在commit 96b2d4f中测试:
在那里你可以看到接受的各种格式:
> rfc2822:Mon,3 Jul 2006 17:18:43 0200
> iso8601:2006-07-03 17:18:43 0200
> local:Mon Jul 3 15:18:43 2006
> short:2006-07-03(不是在1.9.1,工程在2.3.0)
> relative:see commit 34dc6e7:
5.seconds.ago,
2.years.3.months.ago,
'6am yesterday'
> raw:see commit 7dff9b3(git 1.6.2,2009年3月)
内部原始git格式 – 自纪元以来的时间加上时区
(换句话说:“date”%s%z“’format)
> default:Mon Jul 3 17:18:43 2006 0200
Does it accept 2006-07-03 15:18:43 for local?
Yes it does work and it takes the local time zone automatically.
With that format I don’t need to bother which day of the week it is (Sun, Mon, etc).