js算出对称的年月日

      for (let year = 2000; year <= 2060; year++) {
        const str = String(year)
          .split('')
          .reverse()
          .join('')
        const month = str.substring(0, 2)
        const day = str.substring(2, 4)
        const time = year + '/' + month + '/' + day
        if (!isNaN(new Date(time))) {
          console.log(time)
        }
      }

result:

 

posted @ 2021-12-03 14:01  吴小明-  阅读(32)  评论(0编辑  收藏  举报