我有一个正在使用的时间戳time.Now().Format(time.RFC3339)。格式是2018-10-17T07:26:33Z但是,我想要 ISO 8601 中的格式:2018-10-17T07:26:33.000Z
我如何最终获得这些额外的毫秒数?
制作自定义布局,如下所示
package main
import (
"fmt"
"time"
)
func main() {
t1, e := time.Parse(
time.RFC3339,
"2018-10-17T07:26:33Z")
if e != nil {
fmt.Println(e)
}
//2018-10-17T07:26:33.000Z required
//Layouts must use the reference time Mon Jan 2 15:04:05 MST 2006
fmt.Println(t1.Format("2006-01-02T15:04:05.000Z"))
}
Run Code Online (Sandbox Code Playgroud)
游乐场链接(好主意 Sunny)https://play.golang.org/p/Y3II7lGZB-D