vue.js·获取当前时间:
js·获取当前时间:
funGetDateTime(e){ //获取当前时间 var now = new Date(); var Day = now.getDate();//日 var Month = now.getMonth();//月 var Year = now.getFullYear();//年 var Week = now.getDay();//星期 var unixtime = now.getTime();//时间戳 var h = now.getHours();//时 var m = now.getMinutes();//分钟 var s = now.getSeconds();//秒 var ms = now.getMilliseconds();//毫秒 let obj = { year: Year, month: Month +1, day: Day, week: Week, unixtime: unixtime, h:h, m:m, s:s, ms:ms } console.log(obj); return obj; },
js 两个日期天数差
funDateDiff(old,news){//日期计算天差 输入方式2022-07-12 var sArr = old.split("-"); var eArr = news.split("-"); var sRDate = new Date(sArr[0], sArr[1], sArr[2]); var eRDate = new Date(eArr[0], eArr[1], eArr[2]); var result = (eRDate - sRDate)/(24*60*60*1000); return result ; }
1,008 Views