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.

27 lines
440 B

  1. package Helper
  2. import (
  3. "time"
  4. )
  5. func FormatTimestamp(t interface{}) string {
  6. var (
  7. s string
  8. tt time.Time
  9. exists bool
  10. )
  11. // Check if timestamp is string
  12. s, exists = t.(string)
  13. if exists {
  14. return s
  15. }
  16. // Check if timestamp is time.Time
  17. tt, exists = t.(time.Time)
  18. if !exists || tt.IsZero() {
  19. return ""
  20. }
  21. loc, _ := time.LoadLocation("Australia/Adelaide")
  22. return tt.
  23. In(loc).
  24. Format("02/01/2006 03:04 PM")
  25. }