Skip to content

Instantly share code, notes, and snippets.

@wadackel
Last active September 15, 2016 01:44
Show Gist options
  • Save wadackel/a7eaebe20fe61294126eb7e15e9548dd to your computer and use it in GitHub Desktop.
Save wadackel/a7eaebe20fe61294126eb7e15e9548dd to your computer and use it in GitHub Desktop.
Convert absolute time from relative time in GitHub, for Chrome. (Example: 15 minutes ago -> 2016-09-15 10:06:20)
// Original
(() => {
"use strict";
const el = document.querySelectorAll("time-ago,relative-time") || [];
const pad = s => `0${s}`.slice(-2);
Array.prototype.forEach.call(el, o => {
const d = new Date(o.getAttribute("datetime"));
o.textContent = [
`${d.getFullYear()}-`, `${pad(d.getMonth() + 1)}-`, `${pad(d.getDate())} `,
`${pad(d.getHours())}:`, `${pad(d.getMinutes())}:`, `${pad(d.getSeconds())}`
].join("");
});
})();
// Bookmarklet
// javascript: (()=>{"use strict";const el=document.querySelectorAll("time-ago,relative-time")||[];const pad=s=>`0${s}`.slice(-2);Array.prototype.forEach.call(el,o=>{const d=new Date(o.getAttribute("datetime"));o.textContent=[`${d.getFullYear()}-`,`${pad(d.getMonth()+1)}-`,`${pad(d.getDate())} `,`${pad(d.getHours())}:`,`${pad(d.getMinutes())}:`,`${pad(d.getSeconds())}`].join("");});})();void 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment