I have dates in postgres table. The dates are stored with a UTC timezone.
Example from python.
roster = Roster.objects.get(id=266438)
roster.start_timestamp
Out[11]: datetime.datetime(2018, 9, 7, 15, 0, tzinfo=<UTC>)
When I marshall these dates from within go lib/pq my local time zone is somehow being applied.
func (nt *pq.NullTime) MarshalJSON() ([]byte, error) {
if !nt.Valid {
return []byte("\"\""), nil
}
val := fmt.Sprintf("\"%s\"", nt.Time.Format("01/02/2006 15:04:05"))
fmt.Println("Marshalling FMPDateTime", nt, val)
return []byte(val), nil
}
Example log:
Marshalling DateTime &{2018-09-08 00:30:00 +0930 ACST true} "09/08/2018 00:30:00"
2018-09-08 00:30:00 +0930 ACST is 2018-09-07 15:00:00 UTC.
How do you JSON Marshall a pq.NullTime in UTC rather than the local timezone?