javascript dates in firefox and locales

Tim Abell · September 27, 2016

Reading time: 1 minute

Today I learnt:

You actually have to reinstall firefox using a different download to get new Date(dateString) to use a different date format (i.e. non-US).

https://jqueryvalidation.org/date-method/

This method should not be used, since it relies on the new Date constructor, which behaves very differently across browsers and locales. Use dateISO instead or one of the locale specific methods (in localizations/ and additional-methods.js).

So if you’re using chocolatey or boxstarter like I am (my boxstarter script) you need to add the locale flag: https://chocolatey.org/packages/firefox

choco install Firefox -packageParameters "l=en-GB".

Reinstalling the package with --force is sufficient to change it.

It would seem chrome has no way change the format from en-US.

To be clear the correct solution is to do as the documentation says and not use that method, however it’s a bit mean having a pitfall like that in the API. And sometimes you just have to work with the code you have…


Share: Tweet | LinkedIn
Suggest improvements: page source on github

Get extra content that's just for my list. Get new blog posts to your inbox.
Join me on my journey through software and business.