获取当前日期

痛定思痛。 2022-12-23 09:49 430阅读 0赞
  1. var myDate = new Date();
  2. var nowDate = myDate.getFullYear();
  3. nowDate = nowDate + ((myDate.getMonth() + 1) < 10 ? "年" + (myDate.getMonth() + 1) : "年" + (myDate.getMonth() +
  4. 1));
  5. nowDate = nowDate + (myDate.getDate() < 10 ? "月" + myDate.getDate() : "月" + myDate.getDate()) + '日';
  6. console.log(nowDate);

发表评论

表情:
评论列表 (有 0 条评论,430人围观)

还没有评论,来说两句吧...

相关阅读