#Cant tell if time.Now() is screwed up
59 messages ยท Page 1 of 1 (latest)
Time zone issue ?
I've tried everything on the frontend
ive converted to the local timezone, while that fixed the timestamp sqlc gives, the one timestamp that i send when a user sends a message is an hour early
I cant really tell, since even that timestamp would go through the conversion and yet it stays the same.
Well
Rather that the timezone conversion fixes sqlc, while it screws up the timestamp I send when a user sends a message.
So either way you flip it you have an issue
My only thought is that it's just screwed up cause this makes no sense
what exactly is wrong about "Formatted Time (UTC): 6:08 PM"? it is currently 6:14 UTC
that is correct
what matters to me is local time, so i display it, it's off, it's either an hour ahead or an hour earlier, an hour earlier is the issue if i convert timezones but its an hour ahead if i dont
this just sounds like you need to format in local time zone on the front-end
well it sounds like that but you use the local timezone, while it fixes the first issue now you have another
then it sounds like your front-end is providing incorrect or ambiguous information to the back-end
timezones should really only come into play in displaying things, not the absolute value of timestamps
i fail to see how this has anything to do with Go's time handling
i have no idea
ive never had this issue because i dont typically use go for something like this
i really don't think it does
i would focus on your front-end here
note that because RFC 3339 contains timezone information, there are multiple equivalent ways to represent a time
e.g., 2024-11-30T18:08:32Z is the exact same time as 2024-11-30T19:08:32+01:00
it provides a hint towards what timezone might be correct to display, but they are the same time
one is not more right than the other
well look, 2024-11-30T19:23:08.283Z 2024-11-30T18:23:44.000Z
the 1st one is when messages are fetched
how is that time being generated?
2nd one is when a user sends a message and i'm generating a timestamp with time.Now().UTC().Format(time.RFC3339)
the first
how can i be more specific
I convert to isostring() on the frontend, so that both are formatted the same way. now
When you said the 1st is when messages are being fetched. You mean that's the time that the frontend said it first requested information?
it's being pulled from the database
inserting
TIMESTAMP DEFAULT NOW()
okay, that's the specificity i was after. ๐
you should use TIMESTAMP WITH TIME ZONE
otherwise, the database stores local-time timestamps without time zone information
alright
this makes it impossible to interpret the data without assuming that the timestamp was the same at insertion time as it is at query time
and even if you assume that, you still need to have more logic to incorporate that local time offset