JS获取当前日期字符串

不念不忘少年蓝@ 2022-05-17 11:24 1179阅读 0赞
  1. function getDate() {
  2. var date = new Date();
  3. var month = date.getMonth() + 1;
  4. var strDate = date.getDate();
  5. if (month >= 1 && month <= 9) {
  6. month = "0" + month;
  7. }
  8. if (strDate >= 0 && strDate <= 9) {
  9. strDate = "0" + strDate;
  10. }
  11. var currentDate = date.getFullYear() + '年' + month + '月' + strDate + '日';
  12. return currentDate;
  13. }

发表评论

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

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

相关阅读