I need to get the current date but I can't figure out how to format it the way I need.
Every method Ive found separates the values with -
and i need them separated with /
.
Ive tried doing it the long way like:
const today = new Date();
let dd = today.getDate();
let mm = today.getMonth()+1;
const yyyy = today.getFullYear();
if(dd<10)
{
dd='0'+dd;
}
if(mm<10)
{
mm='0'+mm;
}
today = yyyy+'/'+mm+'/'+dd;
This works but it is messy and causes some TS errors as the values are numbers and Im treating them like strings. Ive also tried
const date = new Date().toISOString().split(“T”)[0];
Which gives me the date in the correct order but separated by -
is there any method that will format the current date separated by /
?