how to get formatted date in javascript code example
Example 1: js date now format
new Date().toJSON()
Example 2: javascript date format
Modern JavaScript date utility library https:
date-fns provides the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js.
Example 3: get date format javascript
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
}