How to show date and time of a commit by hash

The normalized way to reference a commit is abbreviated hash (subject, date), without the time. It is called a "reference".

With Git 2.25 (Q1 2020), "git log" family learned "--pretty=reference" that gives the name of a commit in the format that is often used to refer to it in log messages.

And that format is close to what you are looking for.

See commit 3798149, commit 1f0fc1d, commit 618a855, commit ac52d94, commit 3e8ed3b, commit 4982516, commit f0f9de2, commit fb2ffa7, commit bae74c9, commit bd00717 (20 Nov 2019) by Denton Liu (Denton-L).
See commit 0df6211 (20 Nov 2019) by René Scharfe (rscharfe).
(Merged by Junio C Hamano -- gitster -- in commit d37cfe3, 10 Dec 2019)

pretty: provide short date format

Signed-off-by: René Scharfe
Signed-off-by: Denton Liu

Add the placeholders %as and %cs to format author date and committer date, respectively, without the time part, like --date=short does, i.e. like YYYY-MM-DD.

Why?
Because of contribution and patch:

pretty: implement 'reference' format

Based-on-a-patch-by: SZEDER Gábor
Signed-off-by: Denton Liu

The standard format for referencing other commits within some projects (such as git.git) is the reference format.
This is described in Documentation/SubmittingPatches as:

If you want to reference a previous commit in the history of a stable branch, use the format "abbreviated hash (subject, date)", like this:

....
    Commit f86a374 (pack-bitmap.c: fix a memleak, 2015-03-30)
    noticed that ...
....

Since this format is so commonly used, standardize it as a pretty format.

The pretty-formats documentation now includes:

'reference'

<abbrev hash> (<title line>, <short author date>)

This format is used to refer to another commit in a commit message and is the same as --pretty='format:%C(auto)%h (%s, %ad)'.
By default, the date is formatted with --date=short unless another --date option is explicitly specified.
As with any format: with format placeholders, its output is not affected by other options like --decorate and --walk-reflogs.


Before Git 2.25, as shown in WisdmLabs's answer, you might do:

git show -s --date=short --pretty='format:%h (%s, %ad)' <commit>

Now (Git 2.25+):

git show -s --pretty=reference <commit>

Example with Git 2.32 (Q2 2021), and "log --format=..." that show timestamps in various formats.

See commit 3593ebd, commit fbfcaec (25 Apr 2021) by Ævar Arnfjörð Bjarmason (avar).
(Merged by Junio C Hamano -- gitster -- in commit e5d99d3, 07 May 2021)

pretty tests: simplify %aI/%cI date format test

Signed-off-by: Ævar Arnfjörð Bjarmason

Change a needlessly complex test for the %aI/%cI date formats (iso-strict) added in 466fb67 ("pretty: provide a strict ISO 8601 date format", 2014-08-29, Git v2.2.0-rc0 -- merge) to instead use the same pattern used to test %as/%cs since 0df6211 ("pretty: provide short date format", 2019-11-19, Git v2.25.0-rc0 -- merge listed in batch #5).


I'm now trying to find the date and time for when fe1ddcdef took place

"Took place" is not well defined, but I can note that every commit has two date-and-time stamps associated with it: the author date and the commit date.

Typically these two are the same, unless you use any of the various options that copy commits, in which case the author timestamp is the date it was first committed and the committer timestamp is when that particular commit was made.

Both timestamps are under the complete control of the user. Typically people don't override them, though, so that they're as accurate as their own computer's clock (i.e., not very).

To see both dates, use, e.g.:

git log --no-walk --pretty=fuller fe1ddcdef

To see just one, you can leave out the format, or use git show <hash> (which also shows a diff). To get just the date or dates, use --pretty=format:<directives> or --format=<directives>. The directives that print the author date have the form %a<letter> and those that print the committer date have the form %c<letter>, where the <letter> part is one of d, D, r, t, i, or I. For more details see the PRETTY FORMATS section of the git log documentation.


You can try --date

git reflog --date=iso

It will give you timstamp with each hash:

cd7c3721 HEAD@{2021-03-25 16:47:42 +0100}: commit: Updated paths
644bc38f HEAD@{2021-03-25 01:28:32 +0100}: commit: Add feign router
c7d62f34 HEAD@{2021-03-25 01:14:42 +0100}: commit: Add feign config
fdaedc9e HEAD@{2021-03-25 01:12:31 +0100}: commit: Add test config

You can also make your own formats using git pretty formats. Also look at this answer for more options.


Simply use :

git show fe1ddcdef

… to display the content of the commit. Actually, once you have any expression that identifies a commit object, you can use it in all places that require a revision. These expressions can be an hexadecimal hash (even partial), a branch name or a tag name. It can also be one of these, associated to one or many operators such as "^", or "~", or "@".

This means that you can also use git log fe1ddcdef to get the full history of the branch starting from this point.

If you want to get only date and time of it and nothing else, you can type :

git show --no-patch --no-notes --pretty='%cd' fe1ddcdef

Replace '%cd' by '%h %cd %s' to add hash summary and commit's subject message.

Tags:

Git