To format a date in the format month day, year hour:minute:second.fff am/pm zzz
in Go, you can use the time
package's Format
function. Here's an example:
main.go135 chars12 lines
Output:
main.go31 chars2 lines
In the format string, January
represents the full month name, 2
represents the day of the month, 2006
represents the year (in the format of the year), 3
represents the hour (in the 12-hour format), 04
represents the minute, 05
represents the second, .000
represents the millisecond, pm
represents the AM/PM indicator, and MST
represents the timezone abbreviation.
gistlibby LogSnag