When I was using jsc Engine, everything was working fine but when I shifted from jsc engine to Hermes Engine in my react native app I started getting Invalid date where I was using moment.
CODE:
const defaultDate = moment(currentTimeStamp).format("YYYY/MM/DD"); //till this it works fine
return moment(defaultDate).toDate().getTime(); // throws INVALID DATE
After some R&D, I was able to figure out the issue myself so I thought to share it here.
Solution 1 :
Instead of using format like format("YYYY/MM/DD");. Use it like format("YYYY-MM-DD"); as this is one of the standard format that moment understands.
Solution 2:
If you need that format only(which was my case). You need to tell the moment the format that you are using. Like this:
return moment(defaultDate,"YYYY/MM/DD").toDate().getTime();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With