Answers for "new date() format yyyy-mm-dd"

2

javascript format date yyyy-mm-dd

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

javascript format date yyyy-mm-dd

let today = new Date()
today.toISOString().split('T')[0]
Posted by: Guest on August-27-2020
3

js date format yyyy-mm-dd

yourDate.toISOString().split('T')[0]
Posted by: Guest on May-12-2020
0

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
Posted by: Guest on March-02-2021
0

Convert a date to yyyy mm dd format

const formatYmd = date => date.toISOString().slice(0, 10);
formatYmd(new Date());
Posted by: Guest on October-21-2020

Code answers related to "new date() format yyyy-mm-dd"

Code answers related to "Javascript"

Browse Popular Code Answers by Language