ie 与 Chrome 时间格式化通用:

new Date(res[i].Time.replaceAll("-", "/")).format("yyyy-MM-dd")

 

 

replaceAll, format是扩展方法

/*    
所以可以用以下几种方式.:
string.replace(new RegExp(strSearch, 'g'), strReplace);
string:字符串表达式包含要替代的子字符串。
strSearch:被搜索的子字符串。
strReplace:用于替换的子字符串。
*/
String.prototype.replaceAll = function(strSearch, strReplace, ignoreCase) {
    if (!RegExp.prototype.isPrototypeOf(strSearch)) {
        return this.replace(new RegExp(strSearch, (ignoreCase ? "gi" : "g")), strReplace);
    } else {
        return this.replace(strSearch, strReplace);
    }
}

/**
* 将时间转换成固定格式输出
* new Date().toFormat('yyyy-MM-dd HH:mm:ss');
* new Date().toFormat('yyyy/MM/dd hh:mm:ss');
* 只支持关键字(yyyy、MM、dd、HH、hh、mm、ss)HH:表示24小时,hh表示12小时
*/
Date.prototype.format = function(format) {
    var o = {
        "M+": this.getMonth() + 1, //month
        "d+": this.getDate(), //day
        "h+": this.getHours(), //hour
        "m+": this.getMinutes(), //minute
        "s+": this.getSeconds(), //second
        "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
        "S": this.getMilliseconds() //millisecond
    }

    if (/(y+)/.test(format)) {
        format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }

    for (var k in o) {
        if (new RegExp("(" + k + ")").test(format)) {
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
        }
    }
    return format;
}

ie 与 Chrome 时间格式化问题.的更多相关文章

  1. 国际化相对时间格式化API:Intl.RelativeTimeFormat

    原文:The Intl.RelativeTimeFormat API 作者:Mathias Bynens(@mathias) 现代 Web 应用程序通常使用"昨天","4 ...

  2. strftime 日期时间格式化

    strftime() 函数根据区域设置格式化本地时间/日期,函数的功能将时间格式化,或者说格式化一个时间字符串. size_t strftime(char *strDest,size_t maxsiz ...

  3. javascript 时间格式化

    添加扩展 //时间格式化扩展Date.prototype.format = function(format){ var o = { "M+" : this.getMonth()+1 ...

  4. js时间格式化

    const formatDate = timestamp => { const date = new Date(timestamp); const m = date.getMonth() + 1 ...

  5. js对特殊字符转义、时间格式化、获取URL参数

    /*特殊字符转义*/ function replace_html(str) { var str = str.toString().replace(/&/g, "&" ...

  6. 特殊字符转义&时间格式化&获取URL参数

    /*特殊字符转义*/ function htmlspecialchars (str) { var str = str.toString().replace(/&/g, "&& ...

  7. 【AspNetCore】【WebApi】扩展Webapi中的RouteConstraint中,让DateTime类型,支持时间格式化(DateTimeFormat)

    扩展Webapi中的RouteConstraint中,让DateTime类型,支持时间格式化(DateTimeFormat) 一.背景 大家在使用WebApi时,会用到DateTime为参数,类似于这 ...

  8. EasyUI Datagrid Datetime(EasyUI DataGrid 时间格式化)

    EasyUI DataGrid 时间格式化 方法一: var Common = { //EasyUI用DataGrid用日期格式化 TimeFormatter: function (value, re ...

  9. js Date 时间格式化的扩展

    js Date 时间格式化的扩展: Date.prototype.format = function (fmt) { var o = { , //月 "d+": this.getD ...

随机推荐

  1. 【Delphi】注册快捷键

    ShortCutToText , TextToShortCut 需 uses Menus; type TForm1 = class(TForm) HotKey1: THotKey; Button1: ...

  2. 关于delphi XE7中的动态数组和并行编程(第一部分)

    本文引自:http://www.danieleteti.it/category/embarcadero/delphi-xe7-embarcadero/ 并行编程库是delphi XE7中引进的最受期待 ...

  3. [读书心得]资料分页的优化,以SQL 2012的 OFFSET-FETCH为例

    这是我的文章备份,原始出处:[读书心得]资料分页的优化,以SQL 2012的 OFFSET-FETCH为例 http://www.dotblogs.com.tw/mis2000lab/archive/ ...

  4. 大话RAC介质恢复---只有备份文件的恢复

    场景:Oracle 10g RAC:数据文件.控制文件.联机日志.参数文件都使用ASM,归档到ASM.完整备份后,删除所有控制文件.联机日志.数据文件:最后利用备份进行不完全恢复. 1.模拟灾难场景( ...

  5. Noise,Error,wighted pocket Algorithm

    错误衡量(Error Measure) 有两种错误计算方法: 第一种叫0/1错误,只要[预测≠目标]则认为犯错,通常用于分类:通常选择,错误比较大的值作为y˜的值 第二种叫平方错误,它衡量[预测与目标 ...

  6. WARNING: /sys/kernel/mm/transparent_hugepage/enabled is

    安装MONGODB 3.0.6的时候提示警告信息,如下: 2015-09-09T11:04:35.011+0800 I CONTROL [initandlisten] ** WARNING: /sys ...

  7. WebClient和HttpReuqest两种网络请求的方式

    相对来说webClient请求的方式比较简单,可以直接通过new的方式创建一个实例,然后调用OpenReadAsync方法传进一个url,最后通过回调函数OpenReadCompleted就可以获取网 ...

  8. centos下各种c++库文件的安装

    Centos编译boost   1.下载最新的boost http://www.boost.org/   2.解压文件 tar -xzvf boost_1_45_0.tar.gz    3.编译bja ...

  9. c中static作用

      1. static 变量 静态变量的类型 说明符是static. 静态变量当然是属于静态存储方式,但是属于静态存储方式的量不一定就是静态变量. 例如外部变量虽属于静态 存储方式,但不一定是静态变量 ...

  10. dubbox使用

    1.命令行下 git clone https://github.com/dangdangdotcom/dubbox 2.mvn install -Dmaven.test.skip=true 跳过测试编 ...