Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
63
rated 0 times [  70] [ 7]  / answers: 1 / hits: 36696  / 8 Years ago, wed, november 9, 2016, 12:00:00

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?


More From » date

 Answers
223

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);

[#60116] Tuesday, November 8, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rianna

Total Points: 67
Total Questions: 113
Total Answers: 113

Location: French Polynesia
Member since Tue, Jul 7, 2020
4 Years ago
;