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.
 
 
 
 

24 line
534 B

  1. package util
  2. import "time"
  3. // FormatTime 格式化时间
  4. func FormatTime(time time.Time) string {
  5. return time.Format("2006-01-02 15:04:05")
  6. }
  7. // ParseTime 将时间字符串转为Time
  8. func ParseTime(str string) (time.Time, error) {
  9. return time.Parse("2006-01-02 15:04:05", str)
  10. }
  11. // UnixMilliTime 将时间转化为毫秒数
  12. func UnixMilliTime(t time.Time) int64 {
  13. return t.UnixNano() / 1000000
  14. }
  15. // UnunixMilliTime 将毫秒数转为为时间
  16. func UnunixMilliTime(unix int64) time.Time {
  17. return time.Unix(0, unix*1000000)
  18. }