js获取当前年月日-YYYYmmDD格式的实现代码
时间:2020-11-08 12:08:13|栏目:JavaScript代码|点击: 次
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;