<p>Go's time formatting strings are uniquely idiosyncratic, and I have not seen any other language use this sort of system:</p>
<ul>
<li>It is based on the exact timestamp for <code>01/02 03:04:05PM '06 -0700</code>, which is &quot;January 2, 15:04:05, 2006, in time zone seven hours west of GMT&quot; <a href="https://pkg.go.dev/time#pkg-constants:%7E:text=January%202%2C%2015%3A04%3A05%2C%202006%2C%20in%20time%20zone%20seven%20hours%20west%20of%20GMT" rel="noreferrer">(source)</a>.</li>
<li>Time formatting strings are the above timestamp formatted into the desired format, e.g. the default datetime format used by the Unix <code>date</code> command can be represented as <code>Mon Jan _2 15:04:05 MST 2006</code>.</li>
<li>The documentation for the <a href="https://pkg.go.dev/time" rel="noreferrer"><code>time</code> package</a> notes that it is a &quot;regrettable historic error&quot; that months come before the days, as in American date formatting.</li>
</ul>
<p><strong>Where did this sort of datetime formatting come from, i.e. was this taken from another language? And why was this method in particular chosen for Go?</strong></p>

<standard-library><history>
Where does Go's datetime formatting pattern come from? And why was it chosen?
CC BY-SA 4.0
2024-03-03T07:13:11.510Z
In what way do you mean "come from"? Are you looking for precedents?
Jasmijn
CC BY-SA 4.0
2024-03-04T03:53:19.393Z
I imagine what they were going for was "I don't want to memorize all of these arcane single-letter abbreviations to make a format string, so we'll just remember this one date". But then, of course, it just moves the goalpost from "memorize format directives" to "memorize the order of numbers in this date". Needless to say, I've never seen this done anywhere else.
Silvio Mayolo
CC BY-SA 4.0
2024-03-04T05:39:56.347Z
"It is a regrettable historic error that the date uses the American convention of putting the numerical month before the day." I'm guessing it is from "American convention", i.e. the developer picked an arbitrary format that they thought is conventional.
user23013
CC BY-SA 4.0
2024-03-04T21:04:38.393Z
@user23013 Although separating the year like that is not common. We usually write MM/DD/YY. Seems like they deliberately chose this format to be weird, maybe even to emphasize how broken the American style can be.
Barmar
CC BY-SA 4.0
2024-03-04T21:10:57.637Z
@SilvioMayolo "This date" isn't random. They just use sequential 2-digit numbers for each field in the date. You only have to remember the order of fields, which I guess they thought would be intuitive for Americans.
Barmar
CC BY-SA 4.0
2024-03-04T21:34:48.900Z
I am an American and I would have to look up that date every time. There's nothing intuitive about the order.
Silvio Mayolo
CC BY-SA 4.0
2024-03-05T17:00:56.260Z
`mm/dd/yyy` is no more "arbitrary" than any other format: it's a direct reflection of spoken English "<name of month> <day>th, <name of year>". I would argue against *using* this convention, though, just as strongly as I would the European convention of `dd/mm/yyyy`, and recommend `yyyy/mm/dd` in its place.
chepner
CC BY-SA 4.0
2024-03-05T20:20:15.777Z
@SilvioMayolo: Agreed. I would probably have chosen something like `12-03-04T5:6:7.8-09` in a subset of ISO 8601 / RFC 3339.
Jörg W Mittag
CC BY-SA 4.0
2024-03-05T22:15:31.913Z
@SilvioMayolo I also agree, which is why I qualified it with "they thought". Maybe it's how the programmer who designed this liked to write dates. But it's pretty close to how Americans write dates and time, the main difference being the location of the year.
Barmar
CC BY-SA 4.0
2024-03-17T19:12:10.947Z
FWIW, the ISO date standard is YYYY-MM-DD, which disambiguates itself from the American convention. (Note the dashes and 4-digit year.)
user76284
# Where does Go's datetime formatting pattern come from? And why was it chosen?
Posted by: username_0 on 2024-03-03
Go's time formatting strings are uniquely idiosyncratic, and I have not seen any other language use this sort of system:

* It is based on the exact timestamp for `01/02 03:04:05PM '06 -0700`, which is "January 2, 15:04:05, 2006, in time zone seven hours west of GMT" [(source)](https://pkg.go.dev/time#pkg-constants:%7E:text=January%202%2C%2015%3A04%3A05%2C%202006%2C%20in%20time%20zone%20seven%20hours%20west%20of%20GMT).
* Time formatting strings are the above timestamp formatted into the desired format, e.g. the default datetime format used by the Unix `date` command can be represented as `Mon Jan _2 15:04:05 MST 2006`.
* The documentation for the [`time` package](https://pkg.go.dev/time) notes that it is a "regrettable historic error" that months come before the days, as in American date formatting.

**Where did this sort of datetime formatting come from, i.e. was this taken from another language? And why was this method in particular chosen for Go?**
**Tags:** standard-library history
> **Comments:**
> **username_1**: In what way do you mean "come from"? Are you looking for precedents?  
> **username_2**: I imagine what they were going for was "I don't want to memorize all of these arcane single-letter abbreviations to make a format string, so we'll just remember this one date". But then, of course, it just moves the goalpost from "memorize format directives" to "memorize the order of numbers in this date". Needless to say, I've never seen this done anywhere else.  
> **username_3**: "It is a regrettable historic error that the date uses the American convention of putting the numerical month before the day." I'm guessing it is from "American convention", i.e. the developer picked an arbitrary format that they thought is conventional.  
> **username_4**: @user23013 Although separating the year like that is not common. We usually write MM/DD/YY. Seems like they deliberately chose this format to be weird, maybe even to emphasize how broken the American style can be.  
> **username_4**: @SilvioMayolo "This date" isn't random. They just use sequential 2-digit numbers for each field in the date. You only have to remember the order of fields, which I guess they thought would be intuitive for Americans.  
> **username_2**: I am an American and I would have to look up that date every time. There's nothing intuitive about the order.  
> **username_5**: `mm/dd/yyy` is no more "arbitrary" than any other format: it's a direct reflection of spoken English "<name of month> <day>th, <name of year>". I would argue against *using* this convention, though, just as strongly as I would the European convention of `dd/mm/yyyy`, and recommend `yyyy/mm/dd` in its place.  
> **username_6**: @SilvioMayolo: Agreed. I would probably have chosen something like `12-03-04T5:6:7.8-09` in a subset of ISO 8601 / RFC 3339.  
> **username_4**: @SilvioMayolo I also agree, which is why I qualified it with "they thought". Maybe it's how the programmer who designed this liked to write dates. But it's pretty close to how Americans write dates and time, the main difference being the location of the year.  
> **username_7**: FWIW, the ISO date standard is YYYY-MM-DD, which disambiguates itself from the American convention. (Note the dashes and 4-digit year.)  
---
## 0 answers
