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

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")
}