Javascript DateDiff

后端 未结 4 1727
星月不相逢
星月不相逢 2021-01-12 04:15

I am having a problem with the DateDiff function. I am trying to figure out the Difference between two dates/times. I have read this posting (What's the best way to calc

4条回答
  •  囚心锁ツ
    2021-01-12 04:42

    function setDateWeek(setDay){
        var d = new Date();
        d.setDate(d.getDate() - setDay); // <-- add this
        var curr_date = d.getDate();
        var curr_month = d.getMonth() + 1;
        var curr_year = d.getFullYear();
        return curr_date + "-" + curr_month + "-" + curr_year;
    }
    
    
    setDateWeek(1);
    

提交回复
热议问题