You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
367 B
17 lines
367 B
package gotime
|
|
|
|
import "time"
|
|
|
|
// Verification 验证字符串是否为时间
|
|
func Verification(str, layout string) (resp time.Time, err error) {
|
|
loc, err := time.LoadLocation("Asia/Shanghai")
|
|
if err != nil {
|
|
return time.Time{}, err
|
|
}
|
|
location, err := time.ParseInLocation(layout, str, loc)
|
|
if err != nil {
|
|
return time.Time{}, err
|
|
}
|
|
return location, nil
|
|
}
|