Sadly, Git isn't consistent about what date and time formats it accepts. The internal, canonical format is a combination of the Unix timestamp (ie seconds since midnight 1 January 1970) and the timezone offset.
For specifying dates, that's somewhat hard to read. I'd use Git's interpretation of ISO 8601 for a format that's relatively easy to read and will always be unambiguous. Depending on the command you're using, you can often get this with --date=iso
as minitech noted. It'll look something like 2012-12-26 23:17:23 +0000
.
(The --date=rfc
version is similarly unambiguous in that it will only be interpreted the same way, but that includes the weekday. I personally object to having that around, since it allows you to specify dates that look valid but where the day doesn't match the date, such as Sun, 26 Dec 2012 01:02:03 +0000
[That's today, a Wednesday].)
For the formats that are, I believe, accepted everywhere, run git help commit-tree
; that man page includes the following (I've slightly reformatted):
Date formats
The GIT_AUTHOR_DATE
, GIT_COMMITTER_DATE
environment variables support the following date formats:
Git internal format: It is <unix timestamp> <timezone offset>
, where <unix timestamp>
is the number of seconds since the UNIX emoch. <timezone offset>
is a positive or negative offset from UTC. For example CET (which is two hours ahead UTC) is +0200
.
RFC 2822: The standard email format as described by RFC 2822, for example Thu, 07 Apr 2005 22:13:13 +0200
.
ISO 8601: Time and date specified by the ISO 8601 standard, for example 2005-04-07T22:13:13
. The parser accepts a space instead of the T
character as well.
Note: In addition, the date part is accepted in the following formats: YYYY.MM.DD
, MM/DD/YYYY
and DD.MM.YYYY
.
Some places use "approxidate" and as such are less fussy, as michas noted. If you fancy digging into this, the code is in Git's date.c
(that link via the Working With Dates in Git link michas posted). For example, the below is from git help revisions
:
Specifying revisions
…
<refname>@{<date>}
, e.g. master@{yesterday}
, HEAD@{5 minutes ago}
: A ref followed the suffix @
with a date specification enclosed in a brace pair (e.g. {yesterday}
, {1 month 2 weeks 3 days 1 hour 1 second ago}
or `{1979-02-26 18:30:00}) specifies the value of the ref at a prior point in time. …