golang将mm-dd-yy的字符串转时间格式
golang的time包可以直接将字符串转为 time时间对象
package main import ( "fmt" "time" ) func main() { t, _ := time.ParseInLocation("01-02-06", "10-14-20", time.Local) fmt.Println(t.Format("2006-01-02")) }
输出:
2020-10-14
I can see a bigger world.