Convert string to date in golang

huangapple go评论73阅读模式
英文:

Convert string to date in golang

问题

我正在尝试将一个日期字符串转换为time(dd/mm/yyyy),但是我遇到了这个错误 -

2009/11/10 23:00:00 parsing time "29/12/2020": month out of range

这是我的代码 - https://play.golang.org/p/X99jId-cI0U

我该如何修复这个问题?

英文:

I am trying to convert a date string to time (dd/mm/yyyy) but I am getting this error -

2009/11/10 23:00:00 parsing time "29/12/2020": month out of range

Here is my code - https://play.golang.org/p/X99jId-cI0U

How do I fix this?

答案1

得分: 1

我相信你的示例代码中的日期格式应该是"02/01/2006"

英文:

I believe the date layout in your sample code should read "02/01/2006".

huangapple
  • 本文由 发表于 2021年11月3日 01:25:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/69814580.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定