Firefox toLocaleDateString off by one day usually but not always
In the Firefox console
new Date(2021,12,31) I see
"Date Mon Jan 31 2022 00:00:00 GMT -600 (CST)
but new Date(2021,12,31).toLocaleDateString() yields
so it appears the day of the month has been decremeted
from 31 to 30.
This happens for me in any tab unless I open the
Preferences tab. In that tab, in the console output,
I get the expected
This has been occurring for a long time on
Firefox for me on -current on at least two
OpenBSD boxes running
Firefox updated with pkg_add -D snap -u
The reason it's a problem is a browser
password manager displaying a credit card
date will decrement the month. For example,
if an expiration date of 01/21 for January 2021
is stored in the password manager, then the
browser extension displays 12/20.
This happens even if I display the browser
extension's data while in the Firefox
I have been informed by the extension developers
that the browser, and not their extension, handles
the date. I've only noticed the problem on
my OpenBSD boxes and not on other operating
I've tried changing the language and unchecking
the "use operating system preferences" box in
I see there was an old bug that has been resolved
in LocaleDateString that caused these off-by-one
errors, but I am guessing it's something else since
the correct date is displayed sometimes -- only
when I use the web developer console in a tab
used by Firefox Preferences.
Creating new profiles, clearing the cache, etc. has
had no effect.
Currently running OpenBSD 6.9-beta (GENERIC.MP)
#449: Sun Apr 4 00:53:21 MDT 2021
new Date(year, monthIndex [, day [, hours [, minutes [, seconds [, milliseconds]]]]])
Integer value representing the month, beginning with 0 for January to 11 for December.
12 is out of range and so behaves unexpectedly.
> so it appears the day of the month has been decremeted
> from 31 to 30.
> This happens for me in any tab unless I open the
> Preferences tab. In that tab, in the console output,
> I get the expected
AFAICT, chrome behaves identically:
> new Date(2021,12,31)
Mon Jan 31 2022 00:00:00 GMT-0800 (Pacific Standard Time)
> new Date(2021,12,31).toLocaleDateString()