js获取年月日

      const date = new Date()
      const options = { year: 'numeric', month: '2-digit', day: '2-digit' }
      const dateString = date.toLocaleDateString('zh-CN', options)
      const [year, month, day] = dateString.split('/')

      console.log(year, month, day)

人工智能学习网站:

https://chat.xutongbao.top

posted @ 2024-03-19 11:18  徐同保  阅读(8)  评论(0编辑  收藏  举报  来源