I am using Date.parse to convert a string to a date in javascript, however, if the string looks like this '10/11/2016' it is interpreted as Oct 11 2016, i need it to be interpreted as Nov 10 2016
Suggestions?
There is no native format in JavaScript for” dd-mmm-yyyy”. To get the date format “dd-mmm-yyyy”, we are going to use regular expression in JavaScript.
Format date with SimpleDateFormat('MM/dd/yy') in Java // displaying date Format f = new SimpleDateFormat("MM/dd/yy"); String strDate = f. format(new Date()); System. out. println("Current Date = "+strDate);
By default Date.parse
consider in this format that month precede the day to be in your case MM/DD/YYYY not as you want DD/MM/YYYY.
I prefer/suggest using 3rd party date parser library as Moment.js
It can take your date-string and the format to be like this:
moment("10/11/2016", "DD-MM-YYYY");
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