current position:Home>JavaScript gets the current date() and converts it to mm / DD / yyyy, June 23, 2022

JavaScript gets the current date() and converts it to mm / DD / yyyy, June 23, 2022

2022-06-24 08:53:09CongJiYong

It is mainly a band that returns single digits 0,2022-06-01 such

 Insert picture description here
Code up

let singDate = {}
singDate.date = new Date()

console.log(singDate.date)

singDate.date =
    singDate.date.getFullYear() +
    '-' +
    ((singDate.date.getMonth() + 1).toString().length == 1
        ? '0' + (singDate.date.getMonth() + 1)
        : singDate.date.getMonth() + 1) +
    '-' +
    (singDate.date.getDate().toString().length == 1
        ? '0' + singDate.date.getDate()
        : singDate.date.getDate())


console.log(singDate.date)

copyright notice
author[CongJiYong],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/175/202206240626545164.html

Random recommended