javascript year month day format code example
Example 1: js get day month year
const d = new Date();
d.getMonth() + 1; // Month [mm] (1 - 12)
d.getDate(); // Day [dd] (1 - 31)
d.getFullYear(); // Year [yyyy]
Example 2: get date format javascript
//Date format
const handleDate = (dataD) => {
let data= new Date(dataD)
let month = data.getMonth() + 1
let day = data.getDate()
let year = data.getFullYear()
if(day<=9)
day = '0' + day
if(month<10)
month = '0' + month
const postDate = year + '-' + month + '-' + day
return postDate
}