Answers for "convert data dd/mm/yyyy to yyyy-mm-dd javascript"

2

javascript format date yyyy-mm-dd

// yyyy-mm-dd
new Date().toISOString().slice(0, 10)
Posted by: Guest on March-29-2021
1

javascript format date to dd-mm-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 =  day+"-"+month+"-"+year;
alert(formattedDate); //28-02-2021
Posted by: Guest on March-02-2021

Code answers related to "convert data dd/mm/yyyy to yyyy-mm-dd javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language