-2

Here is my string 13-12-2017 05:05 AM

Need to convert with (that my expectation) Date 2017-12-13T05:05:00.000Z

Tried

var mydate = '13-12-2017 05:05 AM';
var selectedDate = new Date(mydate);

console.log(selectedDate); //Invalid date format

Amy
  • 163
  • 1
  • 11

2 Answers2

0

you need to rewrite mydate using this format yyyy-mm-dd HH:mm

in your case:

var mydate = '2017-12-13 05:05 AM';
mareks
  • 774
  • 6
  • 5
0

var mydate = '2017-12-13 05:05 AM';
var selectedDate = new Date(mydate);
console.log(moment(selectedDate).format( ));
<script src="https://momentjs.com/downloads/moment.min.js"></script>
vicky patel
  • 699
  • 2
  • 8
  • 14