And after that if I select a date from datepicker it gets converted to “MM/DD/YYYY” and sometimes “NaN/NaN/NaN” because date is taking the place of month. Have a look below:
Kindly look into this matter and suggest necessary solution.
As we have selected 16 Oct 2018 in above datepicker it gets converted to “10/16/2018” which is a invalid date for the datepicker in “DD/MM/YYYY” so it displays “Invalid date”.
Yes, we want to render the date in “DD/MM/YYYY” format when we are fetching it from database. And the rendering is working fine. But as soon as we want to change the date, then above issue is occurring. Is there any work around to resolve this issue?
Hi @aleksandra_budnik thanks for reply agree with you each implementation is different.
Fiddle Link: https://jsfiddle.net/vineetharkut/vk67qycm/15/
My scenario is I will be getting a CSV file in which I don’t know what data type format will be, so that why I first convert it to one format which is “YYYY-MM-DD” by using dateFormat option and as well as making one custom rendering variable to format the date but there is an issue when you see the format date at the output section month getting convert to date and vice versa. Even if you click on the third-row date, you can see that format has been changed to the old format and if you click outside the date picker then you will see date has been changed which is invalid.
Your title says that Date automatically getting converted to MM/DD/YYYY after selection in datepicker But I do not get the same effect. I get the format that you’ve used in the dateFormat (line 29).
What you would like to achieve after clicking on 19th of December 2018?
if you see the date of the second row is “12/01/2018” (which is DD/MM/YYYY) but after formatting to YYYY-MM-DD it becomes “2018-12-01” the date become month and month become to date. I don’t know whether this is a momentJS fault. Similar issue with the third row also.
In third row of above screenshot which you share just have a look carefully when you clicking the drop-down icon to open the date picker the format was “YYYY-MM-DD” but when the date picker open and before clicking on any date in date picker the date format become “DD-MM-YYYY”, I don’t know why the format getting change but if click on any date in date picker then again the format will correct which is “YYYY-MM-DD”.
Is your data column similar to the one is the demo? The algorytm becomes crazy as firstly two rows you want to change YYYY MM DD to YYYY MM DD (just different separators) but then you have YYYY DD MM and in the 4th row it’s YYYY MM DD again.