Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get current date javascript yyyy-mm-dd

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 =  year+"-"+month+"-"+day;
alert(formattedDate); //2021-02-28
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #current #date #javascript
ADD COMMENT
Topic
Name
9+6 =