If you need a specific format, e.g. 14.12.2013, you can get this with a simple string:
var d = new Date(); var curr_date = d.getDate(); var curr_month = d.getMonth() + 1; //Months are zero based var curr_year = d.getFullYear(); alert(curr_date + "-" + curr_month + "-" + curr_year);
Fortunately there are some libraries out there, which cover that gap.
One Library is Sugar, which adds some handy functionality:
With sugar, date and time formatting is as simple as in C#:
It is also possible to localize the output. To achieve this, you have to include the localization file and set up the language, as shown below.
This alerts the date in the German format: 28. Oktober 2013.
If you need to format and parse date and time only, I recommend moment.js, which has a focus only on that. Is also comes with many different supported languages.