其他分享
首页 > 其他分享> > vue时间差

vue时间差

作者:互联网

el-date-picker

标签不加

 

 时间显示为

 

 此时可以用getTime()函数转化为毫秒数进行时间差求值

/**
 * 计算两个时间的差值
 */
export function days(beginTime, endTime) {
    console.log("求天数")

    var dateDiff = endTime.getTime() - beginTime.getTime();//时间差的毫秒数

    var dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000));//计算出相差天数

    return dayDiff;
}

对于标准时间转化yyyy-MM-dd格式用moment直接格式化

TRANSLATE with x English
Arabic Hebrew Polish
Bulgarian Hindi Portuguese
Catalan Hmong Daw Romanian
Chinese Simplified Hungarian Russian
Chinese Traditional Indonesian Slovak
Czech Italian Slovenian
Danish Japanese Spanish
Dutch Klingon Swedish
English Korean Thai
Estonian Latvian Turkish
Finnish Lithuanian Ukrainian
French Malay Urdu
German Maltese Vietnamese
Greek Norwegian Welsh
Haitian Creole Persian  
  TRANSLATE with COPY THE URL BELOW Back EMBED THE SNIPPET BELOW IN YOUR SITE Enable collaborative features and customize widget: Bing Webmaster Portal Back

标签:vue,getTime,时间差,endTime,location,var,document
来源: https://www.cnblogs.com/lyj0810/p/16378465.html