How to convert ISO 8601 time in golang?

If you’re looking for a simple, but not perfect solution consider using time.RFC3339 constant. But also know that there are differences between ISO8601 which are too complex for this answer.

See https://ijmacd.github.io/rfc3339-iso8601/ for differences and also has a handy test file generator to show differences. There is also a good discussion on SO here What’s the difference between ISO 8601 and RFC 3339 Date Formats?

package main

import (
    "time"
    "fmt"
)

func main(){
    fmt.Println(time.Now().Format(time.RFC3339))
}

golang Time.Format

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)