fix bug
This commit is contained in:
@ -1,3 +1,11 @@
|
||||
/*
|
||||
* @Author: your name
|
||||
* @Date: 2021-11-29 10:04:12
|
||||
* @LastEditTime: 2021-12-15 20:50:49
|
||||
* @LastEditors: Please set LastEditors
|
||||
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
* @FilePath: \tms-obc-web\src\app\shared\utils\date.util.ts
|
||||
*/
|
||||
export class EADateUtil {
|
||||
/**
|
||||
* @description 时间戳转换日期
|
||||
@ -53,4 +61,41 @@ export class EADateUtil {
|
||||
static dateDiff(start: Date, end: Date): number {
|
||||
return start.getTime() - end.getTime();
|
||||
}
|
||||
/**
|
||||
* @description 国际时间转换成YYYY-MM-DD 00:00:00
|
||||
* @param start 开始日期
|
||||
* @returns YYYY-MM-DD 00:00:00
|
||||
*/
|
||||
static yearToDateTime(start: Date): number {
|
||||
let Dates : any='';
|
||||
if(typeof(start) !== 'string') {
|
||||
var c = new Date(start);
|
||||
Dates = c.getFullYear() + '-' + this.addPreZero(c.getMonth() + 1) + '-' + this.addPreZero(c.getDate()) + ' ' + this.addPreZero(c.getHours()) + ':' + this.addPreZero(c.getMinutes()) + ':' + this.addPreZero(c.getSeconds())
|
||||
} else {
|
||||
return start;
|
||||
}
|
||||
return Dates;
|
||||
}
|
||||
/**
|
||||
* @description 国际时间转换YYYY-MM-DD
|
||||
* @param start 开始日期
|
||||
* @returns YYYY-MM-DD
|
||||
*/
|
||||
static yearToDate(start: Date): number {
|
||||
let Dates : any='';
|
||||
if(typeof(start) !== 'string' ) {
|
||||
var c = new Date(start);
|
||||
Dates = c.getFullYear() + '-' + this.addPreZero(c.getMonth() + 1) + '-' + this.addPreZero(c.getDate());
|
||||
} else {
|
||||
return start;
|
||||
}
|
||||
return Dates;
|
||||
}
|
||||
static addPreZero(num: any) {
|
||||
if(num<10){
|
||||
return '0'+num;
|
||||
} else {
|
||||
return num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user