3 ms·
There’s a footgun when you convert DOBs to Date objects. This can return different dates depending on the local timezone: ``` new Date("1/1/2021").toLocaleDate
by stevula 5y ago
There’s a footgun when you convert DOBs to Date objects. This can return different dates depending on the local timezone:
```
new Date("1/1/2021").toLocaleDateString()
```
If you want it to return the same DOB regardless of local timezone, you have to pass a timezone to the Date constructor, which is not super obvious. This kind of bug is also unlikely to get caught by unit tests unless you’re testing date formatting for different timezones, which you probably wouldn’t do if you’re not aware of the footgun to begin with.