4 ms·
Despite the recommendation timestamptz is not actually good for timezones. I think it converts to UTC but doesn't actually store the time zone!!! That's fine f
by losvedir 8y ago
Despite the recommendation timestamptz is not actually good for timezones. I think it converts to UTC but doesn't actually store the time zone!!!
That's fine for, eg, recording a timestamp, but doesn't work for a scheduled event. What if you want to be able to create a new event for "same time next week"? Impossible without having the time zone.
I had an app where it mattered so we stored the datetime with a timestamp (as UTC) and had a separate column for timezone.
I don't really see the point of timestamptz. In most cases when you're just storing a moment in time, convert it on the frontend and store it as UTC. If the time zone actually matters (scheduled, future events) then timestamptz doesn't cut it, and you need to store the timezone separately anyway, so again might as well just use UTC timestamp again.
Eh, I guess if your programming language doesn't have good time zone support you could lean on postgres for the conversion to UTC, but in most apps you'll have to deal with time and zones on the frontend anyway.
- manigandham 8y agoAgreed. Timestamptz is not good advice and the database storing some different than what you send it is always a source of problems. Standard timestamp datatype always stored in UTC or some specific timezone in another column is the best way to deal with dates.
- banku_brougham 7y agoI disagree. Perhaps I don’t understand your complaint fully. Timestamptz column values are the UTC timestamp, but the returned time zone aware result will depend on your db settings, or even local time of your client. Which i think is what everyone would want. Storing an extra column time zone with a timestamp is just an inconvenient way to implement timestamptz.