|
const timeUtil = {
/* 获取时间类的编号 */
getTimeNO: function() {
let date = new Date();
let obj = new Object();
obj.year = date.getFullYear();
obj.month = this.format(date.getMonth() + 1);
obj.day = this.format(date.getDate());
obj.hours = this.format(date.getHours());
obj.minutes = this.format(date.getMinutes());
obj.seconds = this.format(date.getSeconds());
return obj.year + '' + obj.month + '' + obj.day + '' + obj.hours + '' + obj.minutes + '' + obj.seconds;
},
/* 获取日期(年-月-日 时:分) */
getTime_YMDHM: function() {
let date = new Date();
let obj = new Object();
obj.year = date.getFullYear();
obj.month = this.format(date.getMonth() + 1);
obj.day = this.format(date.getDate());
obj.hours = this.format(date.getHours());
obj.minutes = this.format(date.getMinutes());
return obj.year + '-' + obj.month + '-' + obj.day + ' ' + obj.hours + ':' + obj.minutes;
},
/* 获取日期(年-月-日 时:分) */
getTime_YMDHMS: function() {
let date = new Date();
let obj = new Object();
obj.year = date.getFullYear();
obj.month = this.format(date.getMonth() + 1);
obj.day = this.format(date.getDate());
obj.hours = this.format(date.getHours());
obj.minutes = this.format(date.getMinutes());
obj.seconds = this.format(date.getSeconds());
return obj.year + '-' + obj.month + '-' + obj.day + ' ' + obj.hours + ':' + obj.minutes+ ':' + obj.seconds;
},
/* 获取日期(时:分) */
getTime_HM: function() {
let date = new Date();
let obj = new Object();
obj.hours = this.format(date.getHours());
obj.minutes = this.format(date.getMinutes());
return obj.hours + ':' + obj.minutes;
},
/* 获取日期(年-月-日 时:分) */
getTime_Y: function() {
let date = new Date();
let obj = new Object();
obj.year = date.getFullYear();
obj.month = this.format(date.getMonth() + 1);
obj.day = this.format(date.getDate());
obj.hours = this.format(date.getHours());
obj.minutes = this.format(date.getMinutes());
return obj.year;
},
/* 获取日期(年-月-日) */
getTime_YMD: function() {
let date = new Date();
let obj = new Object();
obj.year = date.getFullYear();
obj.month = this.format(date.getMonth() + 1);
obj.day = this.format(date.getDate());
return obj.year + '-' + obj.month + '-' + obj.day
},
format: function(number) {
return (number < 10 ? ('0' + number) : number);
}
}
|
评分
-
查看全部评分
|