|
|
- package Helper
-
- import (
- "time"
- )
-
- func FormatTimestamp(t interface{}) string {
- var (
- s string
- tt time.Time
- exists bool
- )
- // Check if timestamp is string
- s, exists = t.(string)
- if exists {
- return s
- }
- // Check if timestamp is time.Time
- tt, exists = t.(time.Time)
- if !exists || tt.IsZero() {
- return ""
- }
- loc, _ := time.LoadLocation("Australia/Adelaide")
- return tt.
- In(loc).
- Format("02/01/2006 03:04 PM")
- }
|