Convert date to string

I want to convert the date resulted from the node to dd/MM/yyyy format.
How can I do this in cloud functions?

image

I tried this way, but it didn’t worked.

return new Promise(resolve => {
      console.log(data.variables.mydate);
      let d = data.variables.mydate;
      function pad(s) { return s < 10 ? '0' + s : s; }
      let str = [pad(d.getDate()), pad(d.getMonth() + 1), d.getFullYear()].join('/');
      resolve(str);
});