0

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

Julius A
  • 38,062
  • 26
  • 74
  • 96
InfinityGoesAround
  • 1,011
  • 4
  • 17
  • 31

2 Answers2

0

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.

Jayesh Goyani
  • 11,008
  • 11
  • 30
  • 50
0

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');
Community
  • 1
  • 1
Andrey Etumyan
  • 1,394
  • 11
  • 17