exhtml
10/21/2016 - 7:29 AM

Parse Date with Month In Lette

Parse Date with Month In Lette

/*
Option 1

http://stackoverflow.com/questions/13566552/easiest-way-to-convert-month-name-to-month-number-in-js-jan-01
*/

function getMonthFromString(mon){
   var d = Date.parse(mon + "1, 2012");
   if(!isNaN(d)){
      return new Date(d).getMonth() + 1;
   }
   return -1;
}

console.log(getMonthFromString('Aug'));


/*
Option 2

Using moment.js
*/

var MyDate = moment("10 Aug 2016").format('DD-MM-YYYY');

console.log(MyDate);