package main
import (
"fmt"
"time"
)
func main() {
s := "30/11/2021"
date, error := time.Parse("02/01/2006", s)
if error != nil {
fmt.Println(error)
} else {
fmt.Println(date.Format("2006-01-02"))
}
}
Output
2021-11-30
package main
import (
"fmt"
"time"
)
func main() {
s := "30/11/2021"
date, error := time.Parse("02/01/2006", s)
if error != nil {
fmt.Println(error)
} else {
fmt.Println(date.Format("2006-01-02"))
}
}
2021-11-30