Skip to content

Instantly share code, notes, and snippets.

@falzm
Created November 2, 2014 16:42
Show Gist options
  • Save falzm/e62eacae2a3d8d3ab855 to your computer and use it in GitHub Desktop.
Save falzm/e62eacae2a3d8d3ab855 to your computer and use it in GitHub Desktop.
Convert Nginx' "time_local" to "time_iso8601" date formats
package main
import "fmt"
import "time"
func main() {
commonlogDateFormat := "2/Jan/2006:15:04:05 -0700"
iso8601DateFormat := "2006-01-02T15:04:05-07:00"
parsedDate, err := time.Parse(commonlogDateFormat, "18/Oct/2014:08:53:14 +0200")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(parsedDate.Format(iso8601DateFormat))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment