golang time

网址

官网: https://golang.org/pkg/time

代码记录

time格式化成字符串
const DATETIME_FORMAT              = "2006-01-02T15:04:05.000"
curTime := time.Now().UTC()  // utc时间
logData["timestamp"] = string(curTime.Format(DATETIME_FORMAT))
时间差
sTime := time.Now()
...
eTime := time.Now()
reqCost := float64(eTime.Sub(sTime).Nanoseconds()) / 1e6 // 毫秒上报
Table of Contents