January 26th, 2021 change formate in jquery code example
Example 1: jquery format date
function formatDate(date) {
var d = new Date(date),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
return [year, month, day].join('-');
}
alert(formatDate('05/08/2015'));
Example 2: how make date object in jquery from custom date
var formattedDate = new Date("yourUnformattedOriginalDate");
var d = formattedDate.getDate();
var m = formattedDate.getMonth();
m += 1;
var y = formattedDate.getFullYear();
$("#txtDate").val(d + "." + m + "." + y);