Incorrect time zone handling with Date component

I am storing dates in Azure SQL in UTC, this particular value is: 2022-01-19T04:04:17.787Z

This equates to 8:17pm on the 18th in my local (PST) time zone.

moment(qryInvoicesSelect.data.order_date[0]).format('LL') show this correctly: January 18, 2022.
The table component which has this as is mapped value, moment(self).format('MM/DD/YY'), Says 1/18/22

The Date component says Jan 19, 2022 which is incorrect.` Note this is not the Date Picker, but the Date version of the Text Input.

I thought maybe storing my date/times in local time in the database would fix the issue, but Retool seems to treat all of the dates as UTC so that gets real messy real quick.

I am floating this one to the top as the users are still having this issue.

Hi @bradlymathews, I'm sorry for the slow response here :pensive: Retool does show the dates in UTC. Are you able to wrap your Date component inputs with moment() as in the other cases to display it in your local time?

Dates and time zones are a PITA!

So apparently I have to convert to local time zone for display and then I have to convert back to UTC to save to the database.

If I were storing dates in the local time zone that extra work goes away, but the date component assumes UTC which breaks that. So it seems the way it works is the worst of both worlds? Or am I missing something important?

If I were building my own date component in React or such I would abstract all of that away so I don't have to do extra work with every date field.

So should I move this over to feature requests to include the ability for the date component to do exactly that?

Edit: I was making my tables UTC/Local compatible and noticed that the Date Time column type handles the conversion automatically, no extra work for me. That is what I expected from the date component. The downside is I do need to use the full DateTime type, not just the Date type.

1 Like

Up vote, I also requested under new features. Date only to local time zone. Stripping out the time is a pain if you need to display many date components or date columns.

Hi @bradlymathews @Nicolas, Managing time zones is possible with the Date Time component. Would you be able to use that component instead?

\

Ahh, that looks like what I need!

Or else I guess I could store dates as text on the server as I really do not need the time, and storing just dates in UTC seems very problematic which I guess is why the Data component doesn't even try.

I guess I have just really lucked out on avoiding UTC/time zone issues in the apps/programs/websites I have created in the past (either date/time not customer facing or I used a local DB), so I am learning something new!