常用类型及数据操作方法
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
386 B

3 years ago
  1. package helper
  2. import (
  3. "strconv"
  4. "time"
  5. )
  6. func FormatDateTime(str string) string {
  7. date, err := strconv.ParseInt(str, 10, 64)
  8. if err != nil {
  9. return ""
  10. }
  11. return time.Unix(date, 0).Format("2006-01-02 15:04:05")
  12. }
  13. func FormatDate(str string) string {
  14. date, err := strconv.ParseInt(str, 10, 64)
  15. if err != nil {
  16. return ""
  17. }
  18. return time.Unix(date, 0).Format("2006-01-02")
  19. }