我是靠谱客的博主 细腻汽车,这篇文章主要介绍js获取当前年月日-YYYYmmDD格式的实现代码,现在分享给大家,希望可以做个参考。

js获取当前年月日-YYYYmmDD格式的实现代码

var nowDate = new Date();
 var year = nowDate.getFullYear();
 var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1)
  : nowDate.getMonth() + 1;
 var day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate
  .getDate();
 var dateStr = year + "-" + month + "-" + day;

以上这篇js获取当前年月日-YYYYmmDD格式的实现代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

最后

以上就是细腻汽车最近收集整理的关于js获取当前年月日-YYYYmmDD格式的实现代码的全部内容,更多相关js获取当前年月日-YYYYmmDD格式内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(208)

评论列表共有 0 条评论

立即
投稿
返回
顶部