2021-08-18

vue 时间显示相关问题。

1.获取当前系统时间。

 const nowDate = new Date();

        const date2 = {

          year: nowDate.getFullYear(),

          month: nowDate.getMonth() + 1,

          date: nowDate.getDate(),

        };

        const newmonth = date2.month > 10 ? date2.month : "0" + date2.month;

        const day2 = date2.date > 10 ? date2.date : "0" + date2.date;

====

console.log(date2.year + "-" + newmonth + "-" + day2)


2.计算日期相隔天数。

 let sj = new Date("2021-07-01");

 let sj1 = new Date("2021-12-31");

 console.log(123, parseInt(Math.abs(sj -  sj1)  /  1000  /  60  /  60  /24));


3.集中处理表格中时间显示不正确问题。  2021-09-04T00:00:00.000+0000 => "2021-09-04"

解决:filter。


过滤方法


表单时间显示
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容