Closed
Description
Using ISO8601 is more compact and more accurate as the code below shows: package main import ( "fmt" "os" "encoding/xml" "encoding/json" "time" ) func main() { type T struct { When time.Time `xml:",attr"` } t := &T{time.Now()} xml.Marshal(os.Stdout, t) j, _ := json.Marshal(t) fmt.Println(string(j)) } // Output: <T When="Mon Jan 16 12:29:28 +0000 GMT 2012"></T> {"When":"2012-01-16T12:29:28.802511Z"}