zoukankan      html  css  js  c++  java
  • javascript 比量str今天的日期是,参数diff

    function isToday(str) {
        var d = new Date(str.replace(/-/g, "/"));
        var todaysDate = new Date();
        if (d.setHours(0, 0, 0, 0) == todaysDate.setHours(0, 0, 0, 0)) {
            return true;
        } else {
            return false;
        }
    }

    by default7#zbphp.com


    自己改动。添加diff參数。 diff为天数

    function isToday(str, diff) {
        var d = new Date(str.replace(/-/g, "/"));
        var todaysDate = new Date();
        if (!isNaN(diff)) {
            d.setDate(d.getDate() + diff);
        }
    
        if (d.setHours(0, 0, 0, 0) == todaysDate.setHours(0, 0, 0, 0)) {
            return true;
        } else {
            return false;
        }
    }
    


    版权声明:本文博主原创文章,博客,未经同意不得转载。

  • 相关阅读:
    c#剪切板操作
    eclipse mvn build error tips
    Redis Tips
    IntilliJ Idea 使用中的问题与解决方案
    mongo
    python
    SQL Relative
    sybase update
    run current vim file
    git
  • 原文地址:https://www.cnblogs.com/lcchuguo/p/4841917.html
Copyright © 2011-2022 走看看