to be
a problem slover

go time format generic solution

requirement:

format time in YYYYMMDDHHmmssSSS format, UTC+8 timezone

    t := time.Now()
    ts := fmt.Sprintf("%d%02d%02d%02d%02d%02d%03d",t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(),t.UnixMilli()%1000)

Although there’s so many time format methods, I find this is a generic way.

赞(4) 打赏
欢迎转载,注明出处:刘世明的博客 » go time format generic solution

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下作者

支付宝扫一扫打赏

微信扫一扫打赏