使用js時,如何獲取系統當前時間並且得到格式為"yyyy年MM月"的日期


 

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 + "月";

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM