Javascript function to convert date yyyy/mm/dd to dd/mm/yy

Easiest way, assuming you're not bothered about the function being dynamic:

function reformatDate(dateStr)
{
  var dArr = dateStr.split("-");  // ex input: "2010-01-18"
  return dArr[2]+ "/" +dArr[1]+ "/" +dArr[0].substring(2); //ex output: "18/01/10"
}

If you're sure that the date that comes from the server is valid, a simple RegExp can help you to change the format:

function formatDate (input) {
  var datePart = input.match(/\d+/g),
  year = datePart[0].substring(2), // get only two digits
  month = datePart[1], day = datePart[2];

  return day+'/'+month+'/'+year;
}

formatDate ('2010/01/18'); // "18/01/10"

Use any one of this js function to convert date yyyy/mm/dd to dd/mm/yy

Type 1

function ChangeFormateDate(oldDate){
   var p = dateString.split(/\D/g)
   return [p[2],p[1],p[0] ].join("/")
}

Type 2

function ChangeFormateDate(oldDate)
{
   return oldDate.toString().split("/").reverse().join("/");
}

You can call those Functions by using :

ChangeFormateDate("2018/12/17") //"17/12/2018"

Do it in one line:

date.split("-").reverse().join("-");
// 2021-09-16 => 16-09-2021