import React from "react";
// Rearrange date value to get the order you want... also replace / with a cooler separator like ⋅
export default function App() {
const current = new Date();
const date = `${current.getDate()}/${current.getMonth()+1}/${current.getFullYear()}`;
return (
<div className="App">
<h1>Current date is {date}</h1>
</div>
);
}
{new Date().toLocaleString() + ""}
export function getCurrentDate(separator=''){
let newDate = new Date()
let date = newDate.getDate();
let month = newDate.getMonth() + 1;
let year = newDate.getFullYear();
return `${year}${separator}${month<10?`0${month}`:`${month}`}${separator}${date}`
}