typebot.io
typebot.io copied to clipboard
Cross browser date issue
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
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.
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.
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.