main.go208 chars13 lines
In the code above, we create a time.Time
object representing the date October 13, 2014. We then use the Format()
method to format the date according to the string "January 2, 2006", which produces the desired result of "October 13, 2014".
The string "January 2, 2006" may seem arbitrary, but it is a special reference date used in go's time package formatting. Each of the components of the string corresponds to a different part of the date:
By using this specific string as a reference, we can format dates in a wide variety of styles.
gistlibby LogSnag