package main
import (
"fmt"
"strings"
"time"
)
func main() {
//str := "2006-01-02 15:04:05"
str := "Y-m-d h:i:s"
//str := "ymdhis"
fmt.Println(NowTime(str))
}
func NowTime(str string) string {
str = strings.Replace(str, "Y", "2006", -1)
str = strings.Replace(str, "y", "06", -1)
str = strings.Replace(str, "m", "01", -1)
str = strings.Replace(str, "d", "02", -1)
str = strings.Replace(str, "h", "15", -1)
str = strings.Replace(str, "i", "04", -1)
str = strings.Replace(str, "s", "05", -1)
return time.Now().Format(str)
}
有疑问加站长微信联系(非本文作者)