Answers for "change date format in javascript dd/mm/yyyy"

1

javascript format date mm/dd/yyyy

function pad2(n) {
  return (n < 10 ? '0' : '') + n;
}

var date = new Date();
var month = pad2(date.getMonth()+1);//months (0-11)
var day = pad2(date.getDate());//day (1-31)
var year= date.getFullYear();

var formattedDate =  month+"/"+day+"/"+year;
alert(formattedDate); //03/02/2021
Posted by: Guest on March-02-2021
1

javascript date format mm/dd/yyyy

var date_format = new Date();

document.write(innerHTML = date_format.getMonth()+'/'+ date_format.getDate()+'/'+date_format.getFullYear());
Posted by: Guest on July-05-2020

Code answers related to "change date format in javascript dd/mm/yyyy"

Code answers related to "Javascript"

Browse Popular Code Answers by Language