美文网首页
获取当前的日期

获取当前的日期

作者: 一只懒惰的蜜蜂 | 来源:发表于2017-07-03 17:13 被阅读7次

function getNowFormatDate() {
var date = new Date();
var seperator1 = "-";
var year = date.getFullYear();
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = year + seperator1 + month + seperator1 + strDate;
return currentdate;
}

相关文章

网友评论

      本文标题:获取当前的日期

      本文链接:https://www.haomeiwen.com/subject/oplzcxtx.html