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.
21 lines
408 B
21 lines
408 B
package utils
|
|
|
|
import "time"
|
|
|
|
func Time2StampSecond() int64 {
|
|
t := time.Now()
|
|
millisecond := t.UnixNano() / 1e6
|
|
return millisecond / 1000
|
|
}
|
|
|
|
func Str2FormatDateTime(dateStr, format string, location *time.Location) time.Time {
|
|
if location == nil {
|
|
location = time.Local
|
|
}
|
|
parsedTime, err := time.ParseInLocation(format, dateStr, location)
|
|
if err != nil {
|
|
return time.Time{}
|
|
}
|
|
return parsedTime
|
|
}
|