您的位置:首页 > Web前端 > Vue.js

vue 获取当前时间 格式YYYY-MM-DD

2018-04-21 19:31 1161 查看
函数封装:

/**
* 获取当前时间
* 格式YYYY-MM-DD
*/
Vue.prototype.getNowFormatDate = function() {
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;
};


.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: