Skip to content

Instantly share code, notes, and snippets.

@gosub
Last active December 31, 2017 10:43
Show Gist options
  • Save gosub/10df42119b8b3bd58e2d19c9b8b95456 to your computer and use it in GitHub Desktop.
Save gosub/10df42119b8b3bd58e2d19c9b8b95456 to your computer and use it in GitHub Desktop.
Hacker News Time Machine
var t = new Date();
t.setFullYear(t.getFullYear() - 3);
var past = prompt("HN time machine", t.toISOString().substr(0,10));
if (past != null) {
var p = new Date(past);
var p1 = (new Date(p.getFullYear(), p.getMonth(), p.getDate(), 0, 0, 0, 0).getTime() + "").slice(0,-3);
var p2 = (new Date(p.getFullYear(), p.getMonth(), p.getDate(), 23, 59, 59, 0).getTime() + "").slice(0, -3);
var u = "https://hn.algolia.com/?query=&sort=byPopularity&prefix&page=0&dateRange=custom&type=story&dateStart=" + p1 + "&dateEnd="+ p2;
window.location.href=u;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment