How to Format a Time in Go (The Reference Time

Mon Jan 2 15:04:05 MST 2006)

Format a Go time value using the reference time string Mon Jan 2 15:04:05 MST 2006 with the Format method.

Use the time.Time.Format method with the reference time string "Mon Jan 2 15:04:05 MST 2006" to format a time value. Replace the specific parts of the reference time with your desired format layout.

import "time"

now := time.Now()
formatted := now.Format("Mon Jan 2 15:04:05 MST 2006")