为什么第一种格式有效而第二种格式无效
package main
import (
"fmt"
"time"
)
func main() {
date := "21/07/1993"
in := "02/01/2006"
out := "02-01-2006"
dt, err := time.Parse(in, date)
if err != nil {
fmt.Println(err)
}
fmt.Println(dt.Format(out))
date = "21/07/1993"
in = "02/01/2003"
out = "02-01-2003"
dt, err = time.Parse(in, date)
if err != nil {
fmt.Println(err)
}
fmt.Println(dt.Format(out))
}
输出
21-07-1993
parsing time "21/07/1993" as "02/01/2003": cannot parse "93" as "0"
01-01-1012
https://play.golang.org/p/Ht0XZVs54ta
狐的传说
慕码人8056858
德玛西亚99
相关分类