darjun / blog-comments

博客评论
0 stars 0 forks source link

2020/02/14/godailylib/carbon/ #8

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

Go 每日一库之 carbon - 大俊的博客

简介 一线开发人员每天都要使用日期和时间相关的功能,各种定时器,活动时间处理等。标准库time使用起来不太灵活,特别是日期时间的创建和运算。c

https://darjun.github.io/2020/02/14/godailylib/carbon/

zhuliangnan commented 3 years ago

在格式化中 func main() { t := time.Now() fmt.Println(t.Format("2006-01-02 15:04:05")) //2020-10-16 11:01:16 正确 fmt.Println(t.Format("2006-01-02 10:00:00")) //2020-10-16 100:00:00 错误 fmt.Println(t.Format("2006-01-02 15:03:01")) //2020-10-16 11:11:10 错误

}

用now.Format()方式 其字符串的格式是特定的"2006-01-02 15:04:05",不可以改的。。"2006-01-02 10:00:00" 这个字符串是不合适的 ,希望博主修改一下

darjun commented 3 years ago

在格式化中 func main() { t := time.Now() fmt.Println(t.Format("2006-01-02 15:04:05")) //2020-10-16 11:01:16 正确 fmt.Println(t.Format("2006-01-02 10:00:00")) //2020-10-16 100:00:00 错误 fmt.Println(t.Format("2006-01-02 15:03:01")) //2020-10-16 11:11:10 错误

}

用now.Format()方式 其字符串的格式是特定的"2006-01-02 15:04:05",不可以改的。。"2006-01-02 10:00:00" 这个字符串是不合适的 ,希望博主修改一下

非常感谢指出,我修改一下👍