format dd/mm/yyyy javascript code example

Example 1: javascript format date yyyy-mm-dd

let today = new Date()
today.toISOString().split('T')[0]

Example 2: js date now format

new Date().toJSON()
// "2021-01-12T01:06:54.747Z"

Example 3: 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
  }