const d = new Date("10/07/2022").toLocaleDateString("en-gb").split('/');
const date = d[2] + '-' + d[0] + '-' + d[1];
new Date("10/07/2022")
- create date object with given datetoLocaleDateString
- returns locally formatted date string"en-gb"
- use this locale to get date inm/d/y
formatd[2] + '-' + d[0] + '-' + d[1]
- assemble date components to single stringdate
- will contain date inYYYY-MM-DD
format
group: date
const d = new Date("10/07/2022").toLocaleDateString("en-gb").split('/');
const date = d[2] + '-' + d[0] + '-' + d[1];
console.log(date);
2022-07-10
link_youtube: https://youtu.be/gOA16QGJU_s