See "real" commit date / time in github (hour/day)

59,993

Solution 1

Hover your mouse over the 2 years ago and you'll get the timestamp.

Solution 2

The real date does not appear for me upon hovering "2 years ago", despite the text being wrapped by a <time> element with an iso value under its datetime attribute.

If all else fails, like it did for me, try inspecting the text.

Sample element:

<time datetime="2015-01-22T20:48:13Z" is="relative-time" title="Jan 22, 2015, 2:48 PM CST">7 days ago</time>

Solution 3

you can just use this js bookmark:

javascript:(function() { 
        var relativeTimeElements = window.document.querySelectorAll("relative time");
        relativeTimeElements.forEach(function(timeElement){
        timeElement.innerHTML = timeElement.innerHTML +" -- "+ timeElement.title;
        })
    }()
)

https://gist.github.com/PhilippGrulich/7051832b344d4cbd30fbfd68524baa38

It adds just the correct time: Like this: committed 21 hours ago -- 15. Feb. 2017, 15:49 MEZ

Solution 4

If you're looking for a way to display the date/time permanently without hovering (e.g. for screenshots), the above Javascript-based solutions do not match the latest Github HTML (see comments). And they did not take into account the fact that the timestamps are auto-updated based on a timer ("X minutes ago" has to change every minute), so they will periodically reappear.

The following script seems to work on Github as of 2020-01-27:

(function() {
    var els = window.document.querySelectorAll("time-ago,relative-time");
    els.forEach(function(el) {
        el.innerHTML = "on " + el.getFormattedTitle(); // original timestamp
        el.disconnectedCallback(); // stop auto-updates
    });
})();

You can make this a bookmarklet by prefixing the code with javascript: as in the other JS-based solution.

And if you want to make this a permanent fix, you can save this as a TamperMonkey/Greasemonkey script, as follows:

// ==UserScript==
// @name         Github: always show absolute times
// @match        https://github.com/*
// ==/UserScript==

(function() {
    setTimeout(function() {
        var els = window.document.querySelectorAll("time-ago,relative-time");
        els.forEach(function(el) {
            el.innerHTML += ' <span class="text-small">(' + el.title + ')</span>'; // set original timestamp
            el.disconnectedCallback(); // stop auto-updates
        });
    }, 100); // YMMV, experiment with the timeout
})();

That's not very pretty but it seems to do the job.

Solution 5

I tried @odony's TamperMonkey/Greasemonkey script on Chrome but couldn't get it to work. detachCallback() wasn't recognized. So instead of detaching any callbacks, I simply replaced the <relative-time> node.

// ==UserScript==
// @name         Github: always show absolute times
// @match        https://github.com/*
// ==/UserScript==

(function() {
    document.querySelectorAll("relative-time").forEach(function(el) {
        var parent = el.parentNode;
        var timestamp = el.title;
        var span = document.createElement("span");
        span.innerHTML = timestamp;
        parent.removeChild(el);
        parent.appendChild(span);
    });
})();

Sorry I haven't tested this with other browser, but since this is basic javascript, it should just work. :)

Share:
59,993

Related videos on Youtube

loopbackbee
Author by

loopbackbee

Updated on September 07, 2021

Comments

  • loopbackbee
    loopbackbee over 2 years

    Is there a way to see the date of a commit in github, with day/hour precision? Older commits appear in a "human readable" format, such as "2 years ago" instead of showing the actual date.

    old github commit

    If it's not possible to see the actual date on github, is there a easier workaround than git clone?

  • JD.
    JD. about 10 years
    Thanks. That's "usability" !
  • Greg
    Greg over 9 years
    Same solution for how to see the date on StackOverflow. (Top right, "asked 1 year ago")
  • Nico
    Nico over 9 years
    Thanks. It is quite easy to miss. Not the ideal solution I think. ;-)
  • CF_HoneyBadger
    CF_HoneyBadger about 9 years
    I had no idea you could do this...this helped me out. But I wonder, is there a git command you can enter that'll display this information if you pass in the commit hash?
  • sudo
    sudo about 9 years
    Easy to miss. Couldn't they just show the exact date?
  • dalore
    dalore almost 9 years
    Has nothing to do with their end or time element or anything like that. It's you and your browser. A title attr is displayed by browsers as a tooltip when you hover. No fancy js, no css, nothing. Some people have reported issues with chrome and title attr see stackoverflow.com/questions/21314758/… stackoverflow.com/questions/10391327/…
  • Coty Embry
    Coty Embry about 7 years
    Yours didnt work for me, so I wrote this and it worked; +1 for the inspiration javascript:(function() { var el = document.createElement('div'); document.body.prepend(el); el.innerHTML = document.getElementsByTagName('relative-time')[0].getAttribu‌​te('title');}() )
  • TheRyan722
    TheRyan722 almost 4 years
    Love that you included it as tampermonkey/greasemonkey script, makes this more of an actual solution
  • Daniel Williams
    Daniel Williams over 3 years
    I agree, the solution is a setting to show the date. "2 hours ago" is just terrible in my opinion. Bitbucket does the same. It seems harder to do this - anyone know WHY both choose to show this duration?
  • Bojan Radivojevic Bomber
    Bojan Radivojevic Bomber over 3 years
    That moment when you find this answer and realize that you have already upvoted it...
  • Jay Modi
    Jay Modi over 2 years
    And I pondered the question, what if? And It was already answered "8 years ago"
  • phoog
    phoog over 2 years
    How do you "hover over" anything when you're using a phone?
  • devjme
    devjme over 2 years
    Hi, this is what worked for me! Thanks