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. Java开发、网络爬虫、自然语言处理、数据挖掘简介

    一.java开发 (1) 应用开发,即Java SE开发,不属于java的优势所在,所以市场占有率很低,前途也不被看好. (2) web开发,即Java Web开发,主要是基于自有或第三方成熟框架的系 ...

  2. Android 中 Service AIDL使用

         1.创建两个项目创建两个.aidl文件 2.在传递值的类里面创建Service并且返回接口: 服务返回值onBind public IBinder onBind(Intent intent) ...

  3. int转多进制

    char buf[4]; int len=100; _itoa(len,buf_len,16);//16代表十六进制,可用其他进制

  4. VC++ 使用WebBrowser控件中html文件以资源形式加载

    . . . . //加载资源文件中的HTML,IDR_HTML1就是HTML文件在资源文件中的ID wchar_t self_path[MAX_PATH] = { }; GetModuleFileNa ...

  5. OLTP基准测试脚本

    关键语句:ll /local/sysbenchtest/sysbench-0.5/sysbench/tests/db--查看lua脚本/usr/local/mysql/bin/mysql -u roo ...

  6. Python3基础 用三个双引号 print输出多行文本

    镇场诗:---大梦谁觉,水月中建博客.百千磨难,才知世事无常.---今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ ...

  7. 我的android学习经历27

    前几天忙着学校的互联网+项目比赛,没有时间学习android和发一些东西,主要是这两天太累了,我是项目组长,好多东西去弄,今天已经交稿去进行初赛. 马上收拾收拾心情,继续我的andorid菜鸟之路 加 ...

  8. 【leetcode❤python】102. Binary Tree Level Order Traversal

    #-*- coding: UTF-8 -*-#广度优先遍历# Definition for a binary tree node.# class TreeNode(object):#     def ...

  9. IOS设计模式之一(MVC模式,单例模式)

    iOS 设计模式-你可能已经听说过这个词,但是你真正理解它意味着什么吗?虽然大多数的开发者可能都会认为设计模式是非常重要的,然而关于设计模式这一主题的文章却不多,并且有时候我们开发者在写代码的时候也不 ...

  10. CodeForces 451C Predict Outcome of the Game

    Predict Outcome of the Game Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d &a ...