Domoire Darrell De Freitas

Signal cell_tower GoLang time format


In most languages I've run into so far you do something close to an equivalent of `date.format("Y-M-d hh:mm:ss Z")

It works that way for PHP, Javascript, Python.

Instead, with Go you do date.Format("2006/01/02 03:04:05 PM MST"), which I thought initially meant I could seed a time format with an example of any date I wanted. Upon changing the date to something meaningful to myself I quickly found my timestamps all printing out my custom date format.

It turns out that "2006/01/02 03:04:05 PM MST" has special meaning.

It references the data from the POSIX date command which gives the form:

Jan 2 15:04:05 2006 MST 1 2 3 4 5 6 -7

You can make your date string in any format you want, as long as you use January 2nd at 15:04:05 2006 as the time.

Seemingly chaotic, but knowing the POSIX output makes sense.


style golang