🏠 Home 

ISO time format for StackOverflow

Use ISO time format for Stack Overlow and other Stack Exchange sites


Install this script?
  1. // ==UserScript==
  2. // @name ISO time format for StackOverflow
  3. // @version 2.1
  4. // @name:zh-CN 为 Stack Overflow 及 Stack Exchange 旗下网站启用 ISO 时间格式
  5. // @description Use ISO time format for Stack Overlow and other Stack Exchange sites
  6. // @description:zh-CN 将 Stack Overflow 等 Stack Exchange 旗下174个网站的问答页面默认时间改为类ISO格式的
  7. // @namespace StackOverflow
  8. // @author Patrick
  9. // @license MIT
  10. // @match https://askubuntu.com/questions/*
  11. // @match https://stackapps.com/questions/*
  12. // @match https://superuser.com/questions/*
  13. // @match https://serverfault.com/questions/*
  14. // @match https://mathoverflow.net/questions/*
  15. // @match https://*.stackoverflow.com/questions/*
  16. // @match https://*.stackexchange.com/questions/*
  17. // @grant none
  18. // @run-at document-end
  19. // ==/UserScript==
  20. (function() {
  21. let time_list = document.querySelectorAll("span.relativetime, span.relativetime-clean")
  22. time_list.forEach(function(ele) {
  23. ele.innerText = ele.title;
  24. let t = new Date(ele.title.slice(0,20));
  25. let t1 = new Date(t.getTime() - t.getTimezoneOffset()*60*1000);
  26. let t1_str = t1.toISOString();
  27. ele.innerText = t1_str.slice(0,10) + ' ' + t1_str.slice(11,19);
  28. })
  29. })()