I try to get the correct date format, like this: 24-7-2015
.
date = new Date("24-7-2015").toString({ dateFormat: 'd-M-yy' })
but the output of date is then: Wed Dec 7 00:00:00 UTC+0100 2016
Thank you
I try to get the correct date format, like this: 24-7-2015
.
date = new Date("24-7-2015").toString({ dateFormat: 'd-M-yy' })
but the output of date is then: Wed Dec 7 00:00:00 UTC+0100 2016
Thank you
Please try with the below code snippet.
var date = new Date("24-7-2015") // If this is not worked than check your local system date format
document.write(date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear());
Let me know if any concern.
See this answer
If you want to make it easely, like in your example try to use momentjs
moment('24-7-2015', 'D-M-YYYY').format('DD-MM-YY');