2

I need to get todays date in dd-mon-yyyy in jquery/javascript.

I managed to get the date in dd-mm-yyyy format.

function strpad00(s)
{
    s = s + '';
    if (s.length === 1) s = '0' + s;
    return s;
}

var now = new Date();
var processDate = strpad00(now.getDate()) + "-" 
    + strpad00(now.getMonth() + 1) + "-" + now.getFullYear();  
console.log(processDate);

Can you please help me as how can I get the date format in dd-mon-yyyy format?

This is not a duplicate question because, the answers suggest ways to get the format as 'DD-MM-YYYY' and not 'DD-Mon-YYYY' Please unmark it from being duplicate.

Tushar
  • 1,250
  • 5
  • 16
  • 28
  • From your code I see that you managed to prepare the `dd-mm-yyyy` version not `dd/mm/yyyy` are you sure about the target date format? – veritas Dec 15 '14 at 08:17
  • The answers suggest use of datepicker plugin, but I do not like to use that plugin – Tushar Dec 15 '14 at 08:20

0 Answers0