47

I start on the basis that time information is essential to a computer science-related discussion, since the way to solve an issue in this domains changes completely at high frequency (each couple of years there are new technologies that solves the same original issues). For that reason, dates are the third information I read after the question's title and content.

As discussed in this StackExchange post, Americans are used to read the Anglo-Saxon date format (e.g. Dec 15 '14 or May 10 '11) because it is the way we speak in English (American or British).

People from other countries that just read and write English but don't speak it frequently, just like me, can find this format ambiguous. As an example, I am not able to say if May 10 means the 10th of May or May 2010, since in French we commonly use the format June 44 to represent June 1944 or 31/12 for December 31th (the common rule is always smaller to bigger).

There is a famous and funny picture for that: enter image description here

Why not moving to a ISO 8601-like formatted date time? E.g. 1977/04/22 01:00

Or even better: to a customizable format in the Edit Profile page?

EDIT:

As anwsered by @Martijn Pieters:

hover over any timestamp, you get the full ISO 8601 formatted timestamp already

That is not really efficient to hover over every timestamps while browsing StackOverflow.

Stack Exchange deliberately keeps the number of configuration options to a bare minimum

This bare minimum is a bit subjective. Wouldn't that apply to this minimum?

7
  • 3
    Where do you see an American date format?
    – Oded
    Mar 25, 2015 at 10:01
  • 7
    I think he means "Month Day Year" order is American style and it is certainly hard for me to recognize at a glance. Oct 27, 2015 at 10:31
  • 7
    dude, Stackoverflow people, can't stand anyone talking about their datetime format. look at my post meta.stackoverflow.com/questions/309901/… I got -14 downvotes :D Nov 11, 2015 at 6:17
  • 9
    I would further argue that the default date format, including for visitors not logged in, should be ISO 8601 instead of the current one. If not, at the very least always display the year, and with four digits. I believe this would improve clarity immensely for casual visitors.
    – Vitor Eiji
    Nov 29, 2017 at 5:02
  • 2
    @Tim. Yes the default date should be ISO 8601 and/or a custom date format should be setable. Note, however, 1977/04/22 01:00 is not ISO 8601 compliant. Date separators must be hyphens - E.g. 1977-04-22 01:00 is good. Aug 29, 2019 at 22:09
  • 2
    I have been on SO for some time and I still hate the current date format. I get confused by it on daily basis. Especially when it is something like Mar 15 '16.
    – Dharman Mod
    Aug 29, 2019 at 22:55
  • @HosseinShahdoost It's not an issue with Stack Overflow but your question, that question just doesn't make any sense. However, this question does and agree that a more standard format would make sense.
    – user692942
    Sep 14, 2020 at 14:43

4 Answers 4

17

Greasemonkey script:

// ==UserScript==
// @name        Fix_SO_dates
// @namespace   so_ext
// @include http://*.stackoverflow.com/*
// @include /^https?:\/\/(.*\.)?stackoverflow\.com/.*$/
// @include /^https?:\/\/(.*\.)?serverfault\.com/.*$/
// @include /^https?:\/\/(.*\.)?superuser\.com/.*$/
// @include /^https?:\/\/(.*\.)?stackexchange\.com/.*$/
// @include /^https?:\/\/(.*\.)?askubuntu\.com/.*$/
// @include /^https?:\/\/(.*\.)?mathoverflow\.com/.*$/
// @include /^https?:\/\/discuss\.area51\.stackexchange\.com/.*$/
// @include /^https?:\/\/stackapps\.com/.*$/
// @version     1
// @grant       none
// ==/UserScript==

var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];

// Stolen from https://gist.github.com/jlbruno/1535691
var getOrdinal = function(n) {
   var s=["th","st","nd","rd"],
       v=n%100;
   return n+(s[(v-20)%10]||s[v]||s[0]);
}

var items = document.getElementsByClassName("relativetime");
for (i = 0; i < items.length; i++)
  {
    var dt = items[i].getAttribute("title").split(' ')[0].split("-");
    var year = dt[0];
    var month = monthNames[parseInt(dt[1]) - 1];
    var day = dt[2];
    items[i].innerHTML = "the " + getOrdinal(day) + " day of " + month + " anno Domini " + year;
  }

Produces the following result on posts:

It's a screenshot. Yeah!

Currently it only works reliably on posts. All of the other dates around Stack Overflow can be rewritten using this method, it's just that the includes are not quite perfect, and the jQuery that refreshes the question lists resets the text.

4
  • It probably goes without saying that the date format can be customized to anyone's liking, not just the ridiculous example I used.
    – theB
    Oct 30, 2015 at 15:36
  • Why not just assign the zulu timestamp associated with every relative time stamp to the text content? $('[class*="relativetime"]').each(function(){ this.textContent = this.title });
    – user4639281
    Oct 30, 2015 at 16:01
  • @TinyGiant - Because the thought of using the date format I used amused me too much. :)
    – theB
    Oct 30, 2015 at 16:05
  • It is quite amusing. Here's my version
    – user4639281
    Oct 30, 2015 at 16:09
6

I've just added a fix like this to my userContent.css in Firefox.

It adds an ISO style YYYY-MM-dd to the box and visually hides the existing date's span. I'm sure it can be improved:

/* this doesn't work for multi domains ->  @-moz-document domain(stackoverflow.com) domain(stackexchange.com) */
/* so use regexp instead */
@-moz-document regexp('.*(stackoverflow|stackexchange)\\.com/?.*')
{
span.relativetime { overflow: hidden; color:#fff; }
span.relativetime::before { color:#333;
  content: attr(title) ' ';
  width: 50%;
  display:inline-block;
  height:1em; overflow: hidden;
  white-space: pre-wrap;
  }

span.relativetime-clean { color:#fff; }
span.relativetime-clean::before { color:#333;
  font-weight: bold;
  content: ' ' attr(title) ' ';
  display:inline-block;
  }
}

You'll need to add that for each site on the stackoverflow network, the @document regexp helps but note the need to double-escape some things [that the documentation doesn't really make clear IMO], and it might need adjusting for the particular class used for the span that holds the date if this changes on different network sites.

Example:

data formats displayed on SE/SO altered using userContent.css

2

Personally, I don't think the current format is ambiguous. It may take a second or two to get used to if you are accustomed to other formats, but because the month uses the abbreviated form (and not a numeric form), and the year is prefixed with an apostrophe, I find it to be perfectly understandable.

When you hover over any timestamp, you get the full ISO 8601 formatted timestamp already:

tooltip on a date, with hand-drawn circle

Stack Exchange deliberately keeps the number of configuration options to a bare minimum; you can always create your own User Script (using Greasemonkey / Tampermonkey) to display dates in a different format if you so desire.

10
  • 12
    How is it not an American date format? Americans are almost unique in putting the month before the day and ending with the year. Fields are thus not ordered by magnitude and that makes it confusing for people that are not used to that way of formatting dates.
    – klaar
    Sep 17, 2015 at 7:31
  • 12
    To give you an example: an answer is dated at May 10 '11. I'm interested in knowing the year it was posted in, so I look and I see two digits succeeding the month and think 'so it's posted in the year 2010!'. But alas, it's posted in the year 2011, because for some unknown reason it's deemed not confusing that two couples of digits right next to eachother mean day and year and are in a funny order for foreigners.
    – klaar
    Sep 17, 2015 at 7:34
  • @klaar: us Continental Europeans are spoiled, I know. But even British newspapers still use Monthname Day, Year in places, see en.wikipedia.org/wiki/Date_format_by_country
    – Martijn Pieters Mod
    Sep 17, 2015 at 8:42
  • 9
    We are spoiled, I agree. But the argument of 'but british newspapers use MDY on the cover as well!' is rather weak in defending the current situation against change, I must say. Anyway, I'm not advocating a site-wide change that is bestowed upon every user, but I much rather like a personal setting where I can change this. I foresee that I (and many others!) will greatly benefit from such a thing.
    – klaar
    Sep 17, 2015 at 8:50
  • 1
    The only acceptable arguments in this answers are about Stack Exchange deliberately keep[ing] the number of configuration options to a bare minimum and the possibility to create your own User Script (using Greasemonkey / Tampermonkey). For that reason I accept this answer if @MartijnPieters removes the first part.
    – Tim
    Oct 30, 2015 at 10:09
  • 1
    @Tim: I'm not fussed about an answer being marked accepted or not. Why should the first part go?
    – Martijn Pieters Mod
    Oct 30, 2015 at 10:11
  • 2
    Sorry @MartijnPieters, I should've explained the reasons, here they are. Your first sentence was about a link I replaced since you were right that it was off-topic. In the second sentence it is said that Dec 15 '14 is not an American date format but I replaced American with Anglo-Saxon, even if this date format is more popular in USA than in UK. In the same sentence you say that you don't think the current format is ambiguous but it seems to be, according to others comments and the (new) link I provided.
    – Tim
    Oct 30, 2015 at 12:53
  • Finally, I'd prefer to accept an answer rather than writing my own, paraphrasing the second part of yours, @MartijnPieters. Rgds,
    – Tim
    Oct 30, 2015 at 12:57
  • 1
    @Tim: I've edited the post, but I see that an actual userscript is now available, as I suggested in my answer.
    – Martijn Pieters Mod
    Oct 30, 2015 at 15:53
  • 1
    I've just been bitten by this, "May 10" .. wow that question is old. Except it turns out it's not May 2010 but only a few days ago and so they missed off the disambiguating year. Moronic. And, there's no preference to change it.
    – pbhj
    May 16, 2019 at 12:34
-1

A Greasemonkey script to return the datetime in ISO 8601 format, Zulu time.

// ==UserScript==
// @name        Fix_SO_dates
// @namespace   so_ext
// @include http://*.stackoverflow.com/*
// @include /^https?:\/\/(.*\.)?stackoverflow\.com/.*$/
// @include /^https?:\/\/(.*\.)?serverfault\.com/.*$/
// @include /^https?:\/\/(.*\.)?superuser\.com/.*$/
// @include /^https?:\/\/(.*\.)?stackexchange\.com/.*$/
// @include /^https?:\/\/(.*\.)?askubuntu\.com/.*$/
// @include /^https?:\/\/(.*\.)?mathoverflow\.com/.*$/
// @include /^https?:\/\/discuss\.area51\.stackexchange\.com/.*$/
// @include /^https?:\/\/stackapps\.com/.*$/
// @version     1
// @grant       none
// ==/UserScript==

document.querySelectorAll('[class*="relativetime"]').forEach(element => {
  element.innerText = element.title;
});

Based on @theB's answer and @TinyGiant's comment.

5
  • 2
    The text you change is used by Stack Exchange to show a time relative to now. Stack Exchange has JavaScript that runs periodically to update the text you change. Your changes are overwritten by SE's JavaScript shortly after the code you have is run.
    – Makyen Mod
    Aug 30, 2019 at 0:05
  • It doesn't matter that Stack Overflow periodically updates the relative time format. For the greasemonkey script runs on every page visit or refresh (thereby overwriting SO's changes). At worse you end up with how SO wants to present it until you decide to refresh. All this is in lieu, of course, of Stack Overflow addressing the OP's concern properly and making available ISO8601 dates as a user preference. Aug 31, 2019 at 2:12
  • 2
    You appear to have not understood what I've said, or made the assumption people are willing to reload the page to get back to the YYYY-MM-DD... format. I don't think people are willing to do so. Admittedly, which timestamps are changed back depends on the age of the timestamp. The timestamps for times that were only a short time ago will be overwritten by SE within a minute of when your script runs. For timestamps that are further in the past, they won't be overwritten. For example, if you see this comment within a few minutes, run your script. See how soon it's changed back.
    – Makyen Mod
    Aug 31, 2019 at 2:37
  • So, on your own analysis, it is merely the datetimes for a short time ago that would require a refresh if a user wanted the ISO8601 after SO has rewritten it's default format (some minutes after posting). Most of the datetimes on a typical page, that is, are not going to be rewritten. Therefore, until SO does it properly, for those people that want ISO8601 datetimes this is going to be a useful stop gap whether those users want to also bother with manually refreshing or not. That requires no assumptions about whether users will want to manually refresh. Sep 1, 2019 at 4:29
  • It's going to depend on the page. SE's code updates the relative timestamp information once every minute. Which relative timestamps get updated appears to depend on how recent the timestamp is (i.e. it appears that SE only actually updates the displayed text for the ones where the text would have changed from what they previously had there). On old questions, answers, and comments, that means it could commonly not update while the user was viewing the page. For things that are quite current (e.g. within the last hour), the displayed relative times will update every minute, or even more often.
    – Makyen Mod
    Sep 1, 2019 at 4:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .