JaveScript里实现AddDays

在JavaScript里实现类似C#里的AddDays函数。

Date.prototype.addDays = function (days) {
    var d = new Date().getTime() + (86400000 * days);
    return new Date(d);
    }

注意这里如果用getDate()会有问题,所以只能按秒来加。

Leave a Reply

Your email address will not be published. Required fields are marked *