Ramil Signh Ramil Signh - 5 months ago 10
jQuery Question

How to format date from word to number? Ex. Nov 4, 2004 to 11/04/2004 using JQuery?

I am new to Jquery can anyone help me or give me sample on this one.
How to format date from word to number? Ex. Nov 4, 2004 to 11/04/2004 using JQuery?

Thanks in advance..

Answer

var now = new Date('Nov 4, 2004');
var date = now.getDate();
var year = now.getFullYear();
var month = now.getMonth();
var date1 = date < 10 ? "0"+date : date;
console.log(month+1+"/"+date1+"/"+year)

  1. Add 1 to month because it will start at 0
Comments