初始化
This commit is contained in:
29
utils/wxs/comment.wxs
Normal file
29
utils/wxs/comment.wxs
Normal file
@@ -0,0 +1,29 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* 日期格式化
|
||||
* @param {Date | String | Number} date
|
||||
* @param {String} format 格式
|
||||
*/
|
||||
formatDate: function (date, format) {
|
||||
if (!format) {
|
||||
format = 'YYYY/MM/DD hh:mm:ss';
|
||||
}
|
||||
if (!date) {
|
||||
return '';
|
||||
}
|
||||
date = getDate(date)
|
||||
var YYYY = date.getFullYear();
|
||||
var MM = ('0' + (date.getMonth() + 1)).slice(-2)
|
||||
var DD =('0' + date.getDate()).slice(-2);
|
||||
var hh = ("0" + date.getHours()).slice(-2);
|
||||
var mm = ("0" + date.getMinutes()).slice(-2);
|
||||
var ss = ("0" + date.getSeconds()).slice(-2);
|
||||
var result = format.replace(getRegExp('YYYY'), YYYY)
|
||||
.replace(getRegExp('MM'), MM)
|
||||
.replace(getRegExp('DD'), DD)
|
||||
.replace(getRegExp('hh'), hh)
|
||||
.replace(getRegExp('mm'), mm)
|
||||
.replace(getRegExp('ss'), ss)
|
||||
return result;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user