Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #format #date
ADD COMMENT
Topic
Name
3+8 =