$Id: 169
$SOId: 80100032
If you prefer strftime style of formatting time values (as used in Python or Ruby) or porting code that uses that style, you can use one of several libraries.
Here’s an example using github.com/jehiah/go-strftime package:
// no playground
package main
import (
	"fmt"
	"time"
	strftime "github.com/jehiah/go-strftime"
)
func main() {
	// :show start
	t := time.Date(2017, 9, 4, 3, 38, 45, 0, time.UTC)
	fmt.Println(strftime.Format("%Y-%m-%d %H:%M:%S", t))
	// :show end
}
Side note on package naming: since the package name is strftime, the import path / repository path should be github.com/jehiah/strftime. It’s bad style to add go or go- to repository path.
Unfortunately, when it comes to parsing things are not as good. There are two packages:
but they both are cgo-wrappers around C libraries, which makes them more finicky to build, especially on Windows.
strftime directivesYou can also use http://www.strfti.me/ service to help you build strftime formatting strings.