在github中查看"真实"提交日期(小时/天)

gon*_*opp 144 git date commit github

有没有办法在github中查看提交日期,日/小时精度?较旧的提交以"人类可读"格式出现,例如"2年前",而不是显示实际日期.

老github提交

如果无法在github上看到实际日期,是否有更简单的解决方法git clone

Mat*_* S. 273

将鼠标悬停在上面2 years ago,您将获得时间戳.

  • 谢谢.那是"可用性"! (27认同)
  • 容易错过.他们不能只显示确切的日期吗? (10认同)
  • 使用手机时如何将鼠标“悬停在”任何物体上? (9认同)
  • 有关如何在StackOverflow上查看日期的相同解决方案.(右上角,"问一年前") (8认同)
  • 谢谢.这很容易错过.我认为不是理想的解决方案.;-) (8认同)
  • 我同意,解决方案是设置显示日期。在我看来,“2小时前”太糟糕了。Bitbucket 也做同样的事情。这样做似乎更难 - 有人知道为什么两者都选择显示这个持续时间吗? (4认同)
  • 当你找到这个答案并意识到你已经投了赞成票的那一刻...... (2认同)

Wal*_*man 7

尽管文本被一个<time>在其datetime属性下具有iso值的元素包裹,但是在"2年前"悬停时,真实日期并不适合我.

如果所有其他方法都失败了,就像它对我一样,请尝试检查文本.

样本元素:

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

  • 与他们的结束或时间元素或类似的东西无关.这是你和你的浏览器.当您悬停时,浏览器会将标题attr显示为工具提示.没有花哨的js,没有css,没有.有些人报告了chrome和title attr的问题,请参阅http://stackoverflow.com/questions/21314758/html-title-attribute-not-showing-as-tooltip-in-chrome http://stackoverflow.com/questions/ 10391327/IS-有-A-方式对做标题属性-工作的铬 (3认同)

Phi*_*ich 6

你可以只使用这个js书签:

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

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

它添加了正确的时间:像这样:21 小时前提交 - 2017 年 2 月 15 日,MEZ 15:49


Mr.*_*. T 5

我在 Chrome 上尝试了 @odony 的 TamperMonkey/Greasemonkey 脚本,但无法让它工作。detachCallback()没有被认可。因此,我没有分离任何回调,而是简单地替换了<relative-time>节点。

// ==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);
    });
})();
Run Code Online (Sandbox Code Playgroud)

抱歉,我没有用其他浏览器测试过这个,但由于这是基本的 javascript,它应该可以工作。:)


Von*_*onC 5

2021 年更新:小书签仍然是 GitHub 上的唯一选项。
\n例如,请参阅Justin Noel的“在 GitHub 中显示真实提交时间

\n
javascript:(function() {    \n  var style = document.createElement(\'style\');\n  document.head.appendChild(style);\n  var sheet = style.sheet;\n  sheet.addRule(\'time-ago:before,relative-time:before\', \'content: attr(title);display: block;font-size: 0.5rem;\');  \n})()\n
Run Code Online (Sandbox Code Playgroud)\n

https://pbs.twimg.com/card_img/1432824610794393602/CE26XtQw?format=jpg&name=small

\n
\n

这与GitLab 14.1(2021 年 7 月)形成对比

\n
\n

用户设置显示绝对时间

\n

GitLab 在很多地方显示相对时间(例如 30 分钟前)。

\n

您现在可以更改用户配置文件首选项以显示绝对时间,例如 \xe2\x80\x98 May 18, 2021, 3:57 PM\xe2\x80\x99

\n

绝对时间尊重您的浏览器设置,并根据您首选的区域设置设置日期和时间的格式,例如英国英语而不是美国英语。

\n

这个新的显示选项为需要工作流程(例如将 GitLab 中的操作与外部系统关联)的用户提供了更多信息,一目了然。

\n

dd GitHub

\n

请参阅文档问题

\n
\n

  • 嗨,这对我有用!谢谢 (2认同)