Answers for "convert yyyy-mm-dd to dd-mmm-yyyy in javascript"

2

javascript format date yyyy-mm-dd

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

javascript convert date to yyyy-mm-dd

// `date` is a `Date` object
const formatYmd = date => date.toISOString().slice(0, 10);

// Example
formatYmd(new Date());      // 2020-05-06
Posted by: Guest on July-03-2020
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
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

Code answers related to "convert yyyy-mm-dd to dd-mmm-yyyy in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language