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
  • 33,082
  • 26
  • 68
  • 92
InfinityGoesAround
  • 953
  • 4
  • 15
  • 27

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
  • 10,535
  • 11
  • 24
  • 48
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,183
  • 8
  • 13