typebot.io icon indicating copy to clipboard operation
typebot.io copied to clipboard

Cross browser date issue

Open wejamtech opened this issue 2 years ago • 3 comments

Hey there,

Chrome and Safari both handle dates from the date input block differently and I can't find a method that will capture the intended selection correctly.

If you try and parse a date in Safari, for example using new Date(), it gets days and months mixed up.

The only solution I can think of at the moment is to detect which browser the user is using, and format the dates accordingly.

Is there a better solution?

Thanks, David

wejamtech avatar May 30 '23 10:05 wejamtech

Can you be more precise with your reproduction example?

If you set a variable with the value new Date() by default it will be executed on the server, so that should not change from a browser to another.

baptisteArno avatar May 31 '23 06:05 baptisteArno

I've attached a screenshot of the flow and also the results. As you can see, when trying to parse the date as output from the date block, it gets the day/month the wrong way round.

Ultimately I need to check that a date chosen by the user is not in the past.

Flow Result 2 Result

wejamtech avatar May 31 '23 10:05 wejamtech

Thank you. The issue here is that new Date('31/05/2023') returns Invalid date.

I tried to solve your use case: "Detect if date is before another date". With this date format indeed, it is complicated.

I'll ship someting to make it possible ASAP.

baptisteArno avatar Jun 01 '23 06:06 baptisteArno