getDate(){
// 获取当前时间let date =newDate();// 当前时间转换为时间戳(13位,不足13位要*1000)
date = date.getTime();// 在当前时间戳数据基础上加上一天的时间戳数据(我之前在网上搜了一天的时间戳是86400,怎么转换都是当天,后面才发现没有*1000,*1000是精确到毫秒)
date = date +86400000;// 将操作后的时间戳转换为系统时间格式 let dateInfo =newDate(date);// 将系统时间格式转换为自定义时间格式let year = dateInfo.getFullYear();let month = dateInfo.getMonth()+1;let day = dateInfo.getDate();
month = month >9? month :'0'+ month;;
day = day >9? day :'0'+ day;return`${
year}-${
month}-${
day}`;},
2. 时间转换处理成想要的数据(自定义时分秒,默认开始)
// 日期时间处理为00:00:00functiondateToZeroTime(dateString?: string | Date, timeString ='00:00:00'): number {
const newDate = dateString ?newDate(dateString):newDate();const year = newDate.getFullYear();const month = newDate.getMonth()+1;const date = newDate.getDate();returnnewDate(`${
year}-${
month}-${
date}${
timeString}`).getTime();}
3. 时间转换处理成想要的数据(自定义时分秒,默认结束)
// 日期时间处理为23:59:59functiondateToFinalTime(dateString?: string | Date): number {
const newDate = dateString ?newDate(dateString):newDate();const year = newDate.getFullYear()
1. 系统时间格式转换成自定义格式getDate(type) { // 获取当前系统时间 let date = new Date(); let year = date.getFullYear(); let month = date.getMonth() + 1; let day = date.getDate(); month = month > 9 ? month : '0' + month;; day = day > 9 ? day : '0' + day; r