使用js时,如何获取系统当前时间并且得到格式为"yyyy年MM月"的日期

2023-05-26,,

1.使用js时,如何获取系统当前时间并且得到格式为"yyyy年MM月"的日期

1  var newdate = new Date();
2  var nowyear = newdate.getFullYear();
3  var nowmonth = newdate.getMonth()+1;
4  if (nowmonth >= 1 && nowmonth <= 9) {
5    nowmonth = "0" + nowmonth;
6  }
7  var sysTsuki = nowyear + "年" + nowmonth + "月";

使用js时,如何获取系统当前时间并且得到格式为"yyyy年MM月"的日期的相关教程结束。

《使用js时,如何获取系统当前时间并且得到格式为"yyyy年MM月"的日期.doc》

下载本文的Word格式文档,以方便收藏与打印。