hermes
hermes copied to clipboard
Some date formats that worked in JSC fail with Hermes
Bug Description
When using dates like on the web, for example: 11/30/2000 00:00:00 I get "Invalid Date"
- [x] I have run
gradle clean
and confirmed this bug does not occur with JSC
Hermes version: 0.9.0 React Native version (if any): 0.66.1 OS version (if any): Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64):
Steps To Reproduce
- Pass the format '11/30/2021 00:00:00" in the Javascript Date Builder
- Show result on console
More infos
I tried to rewrite the Date constructor but I get the following message: RangeError: "Date value out of bounds, js engine: hermes"
Hi @luizsn000, could you share a little more about the version of V8 that this work on, and the command you're using? I get an invalid date with the given string on both V8 and JSC:
JSC:
neildhar@neildhar-mbp ~/f/x/m/hermes (default) > ~/.jsvu/javascriptcore
>>> new Date("30/11/2021 00:00:00")
Invalid Date
V8:
neildhar@neildhar-mbp ~/f/x/m/hermes (default)> ~/.jsvu/v8
V8 version 8.7.75
d8> new Date("30/11/2021 00:00:00")
Invalid Date
Hi @luizsn000, could you share a little more about the version of V8 that this work on, and the command you're using? I get an invalid date with the given string on both V8 and JSC:
JSC:
neildhar@neildhar-mbp ~/f/x/m/hermes (default) > ~/.jsvu/javascriptcore >>> new Date("30/11/2021 00:00:00") Invalid Date
V8:
neildhar@neildhar-mbp ~/f/x/m/hermes (default)> ~/.jsvu/v8 V8 version 8.7.75 d8> new Date("30/11/2021 00:00:00") Invalid Date
I noticed my error and edited the issue description. Date format for playback is MM/DD/YYYY hh:mm:ss
I see that both V8 and JSC support this format, so thank you for reporting it. The spec only outlines a date format based on ISO 8601, so using ISO dates is the best way to get consistent behaviour across JS engines. That said, since this is something that other engines support consistently, we should consider adding it.
How can I request the addition of the format in Hermes?
We'll keep this issue open to track the request.
What is the use case for this, since the Date constructor really can't be used reliably to parse arbitrary dates?
This is preventing us from merging Hermes into our application.
Our backend returns a string of 11/30/2000
, and we're using DayJS to format that into something displayed by the end user. DayJS uses native Date constructors under the hood and, after a bit of debugging, ran into this issue.
Would you all be open to receiving a PR that enables this date format?
@luizsn000, please reopen this ticket - as it's not resolved yet.
If you'd like to avoid getting notifications, you can do so on the sidebar, like so

We are in the same boat. Api returns the date in that format and that is what currently stops us from switching hermes on.
return invalid date
for me on ios
Yes this is the exact issue I also have. Really would love to use Hermes. I’m using
new Date().toJson() to create isostring dates but when I pull in the values into my application I get invalid date format
can we have any work around for this , its preventing us from using hermas in 0.72
We are looking into this and will implement a fix in Hermes. We are trying to understand why this is format is considered valid by other engines - Month/Day/Year is very US-centric and doesn't make sense in Europe.
I am also curious to understand the use case for this rather illogical format. Which APIs return non-localized date strings in US format? Isn't that a bug in those APIs?
To be clear, we will match what other engines are doing, but I am trying to better understand the root of the problem.
I've just updated the RN version from 65 to 72 with Hermes enabled and I'm getting the same error message.
[RangeError: Date value out of bounds]
I'm just using dates in this format YYYY-MM-DD
Any update on this?
@andrewdazs I just tried new Date("2023-12-13")
and it is working as expected. Can you share an example that is causing the error for you?
What's causing the error is when I use .toISOString()
to format the date.
Example: new Date("2023-12-12").toISOString()
@tmikov could you try to reproduce with this example?
@andrewdazs I tried it and I don't see an error. Does the error reproduce for you in the Hermes CLI tool?
What's causing the error is when I use
.toISOString()
to format the date.Example:
new Date("2023-12-12").toISOString()
@tmikov could you try to reproduce with this example?
I'm having exactly the same error, for the same situation:
This started when i upgrade to react-native 0.72.6
@leogersen As I said above, I am unable to reproduce this error. Are you seeing the error on iOS or Android?
Can you please try the Hermes CLI tool of your version as well as the CLI tool of the latest Hermes version.
I discovered that at some point of my code I was sending NaN to toISOString()
and this was causing the error. If I see this error again I'll try to look into it in depth.
@luizsn000 I don't think we have addressed this yet?
No, not yet. I'm reverting to JSC on my project as I just found that my date-related bugs are due to Hermes handling them differently and will happily switch back once this has been fixed :)
Hey all!
I'm still getting the error:
I had to use this approach:
if (hini instanceof Date && !isNaN(hini) && hfin instanceof Date && !isNaN(hfin)) {
...
}
Now is working ✅
I really need help with this issue, any approach to a stable solution??