最近对接数据遇到ISO-8601时间格式需要输出,但是time包里面没有,需要自己定义,如下:
package main
import (
"fmt"
"time"
var FormatISOTime = "2006-01-02T15:04:05.000Z07:00"
var FormatISOTimeoOmitted = "2006-01-02T15:04:05.999Z07:00"
func main() {
t := time.Now()
fmt.Println("====0填充")
fmt.Println(t.Format(FormatISOTime))
fmt.Println("====0忽略")
fmt.Println(t.Format(FormatISOTimeoOmitted))
➜ t go run main.go