github.com/billhathaway/strftime

Go library to convert libc strftime conversion specifiers to Go time.Parse/time.Format syntax


License
Apache-2.0
Install
go get github.com/billhathaway/strftime

Documentation

strftime

The standard C strftime(3) library is used to format date/timestamps using conversion specifiers, similar to printf/scanf.

The Go time package uses its own syntax for time.Format() and time.Parse() calls. This package lets you use a strftime format and get back a string that can be passed to time.Format or time.Parse functions.

Usage Example

// Assuming you want to print out in YYYY-MM-DD HH:MM:SS format 
format,err := strftime.New("%Y-%m-%d %H:%M:%S")  
if err != nil {  
  log.Fatal("invalid format")  
}  
fmt.Println(time.Now().Format(format))