1. Count the number of days between two dates

/** * Calculate the number of days between two dates * @param {string} Date_end End date * @param {string} Date_start start date * @return {number} Number of days between iDays */ export function DateDiff(Date_end, Date_start){ let aDate, oDate1, oDate2, iDays; Date_end = Date_end.split(" "); Split ("-"); aDate = Date_end[0]. Split ("-"); ODate1 = new Date(aDate[0],aDate[1],aDate[2]); Date_start = date_start. split(" "); Date_start = date_start. split(" "); aDate = Date_start[0].split("-"); oDate2 = new Date(aDate[0] , aDate[1] , aDate[2]); iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24); // Convert milliseconds to days return iDays; }Copy the code

2. Method introduction

import { DateDiff } from ".. /utils/dateDiff"Copy the code

3. Call and output information on the page

methods: {
    getProjectInfo(){
      console.log(DateDiff('2021-12-20','2021-06-09')) //195
    }
  }
Copy the code