Closed pellizzetti closed 5 years ago
This is directly a shortcoming of Javascript and really hard to write a workaround for.
If you pass the raw string to the new Date
function, it does swap the month with the date, since that is the default format for Javascript.
new Date('02/05/1963')
// Tue Feb 05 1963 00:00:00 GMT+0530 (India Standard Time)
Do u have any suggestions?
This is directly a shortcoming of Javascript and really hard to write a workaround for.
I did not know that (I'm somewhat new to the JS ecosystem) but, yeah, I thought it wouldn't be an easy task.
Do u have any suggestions?
Not at the moment, sorry. But next month, when I have more free time, I can give some attention to the subject and try to get some solutions.
Sure, I will keep this issue opened and see if I can find something solid around it
After looking into multiple ways, I hardly think, there is any way to work around this issue. If you are still looking for a solution, then feel free to open the issue and discuss ways around it
Hi, I'm using Adonis.js, and I'm having the same problem, any news about this?
Anyone else found a workaround for this?
Problem
Using
dateFormat:DD/MM/YYYY
as rule will always fail validation.Behavior
If I make a request with the following data:
Using this rule:
The validation fails. I think that happens because
raw/dateFormat.js
->date-fns/format
is receiving a String has first parameter. Passing a Date object return the right date/format:JSFiddle link
Specifications