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
383 B
17 lines
383 B
package tools
|
|
|
|
import (
|
|
"github.com/golangkit/formatime"
|
|
"time"
|
|
)
|
|
|
|
// StrToSecond 字符串时间转formatime.Second
|
|
func StrToSecond(datetime string, layouts ...string) formatime.Second {
|
|
layout := "2006-01-02 15:04:05"
|
|
if len(layouts) > 0 {
|
|
layout = layouts[0]
|
|
}
|
|
timeDate, _ := time.ParseInLocation(layout, datetime, time.Local)
|
|
return formatime.NewSecondFrom(timeDate)
|
|
}
|