5 ms·
After dealing with datepickers for (checks notes) two decades, my best advice is to use the damn input type text with a placeholder showing a format, then savin
by Muromec 1y ago
After dealing with datepickers for (checks notes) two decades, my best advice is to use the damn input type text with a placeholder showing a format, then saving it as a string in whatever that ISO that makes sense is called.
Everything else is asking for endless trouble and pain with browsers, a11y, locales and what not. Also, may the God allmerciful save you from the cancer that custom components are, let whoever invented this wipe his ass with fiberglass insulation for the end of times.
Don't get fancy and you will not fall down 10 rabbit holes that datepickers are.
- throwaway7783 1y agoAgreed. This works way better than struggling with date pickers not working on mobile, finding where the year picker is etc etc
- tshaddox 1y agoThat’s probably fine for dates that people have memorized, like their birthday. But it’s certainly not great for something like flight search, where I might know I want to leave in early April on a Friday or Saturday. For that I really need to see a calendar not only to input a date, but to visualize the possible dates for my trip.
- padjo 1y agoInput type date shows a calendar: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/date https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/...
- lukan 1y agoYes, but that is not what was recommended here above "my best advice is to use the damn input type text"
- mattmanser 1y agoThis should be called bad advice about dates every developer should avoid. ISO 8601 does NOT work with future dates. It does not work with cross border appointment booking. ISO 8601 only works for dates and times that have already happened. I have 20 years, have worked with apps that relied on future and past dates, have used date pickers since 2005 and would still hesitate to give advice about what is an incredibly complex problem that entirely depends on your use case.
- dotancohen 1y agoTell us more. Please.
- Telaneo 1y ago> ISO 8601 does NOT work with future dates. It does not work with cross border appointment booking. Why is this the case? Is it some time zone shenanigans?
- rendaw 1y agoAnd what format does work for future dates? Or do you mean that ISO 8601 doesn't work but RFC 3339 does work or some other updated ISO/RFC format?
- mattmanser 1y agoI'm not dealing with it anymore, I was when I worked in a couple of restaurant focused SaSSes. Someone else has mentioned RFC 9557. So you might be able to deal with it with 8601 for past dates and 9557 for future.
- mattmanser 1y agoTimezones change, more frequently than you realize. Some countries even used to change when summer time started regularly. It's got better than it used to be afaik. Also you need to take into account where the user is going to be. With future dates, time is relative. So at the very least you often need the time + the timezone of the location. Book me a table at 8, means book me a table in Berlin time at 8, not in San Francisco time at 8. Same with displaying future dates, you need the context of where.
- dotancohen 1y agoNo matter what placeholder text you put, you can not trust that 3-9-1980 is the same date for your user as it is for you.