ie下获取某个时间的毫秒值

在IE浏览器下,若要获取某个时间的毫秒值('2017-12-07 16:49:56.0'),必须先将该时间字符串转换格式再去转换成毫秒值;

       //空判断,也可以用underscore的_.isEmpty()函数
       isEmpty : function(fData) {
			if (typeof fData == "function") {
				return false;
			}
			return typeof fData == "undefined" || fData == undefined || fData == null || 
                   fData.length == 0 || fData == 'null' || (fData != false && fData == '');
		},
		isNull : function(fData, replaceData) {
			return _this.isEmpty(fData) ? replaceData : fData;
		},
        strToDate : function(str) {
			if (_this.isEmpty(str)) {
				return null;
			}
			var converted = Date.parse(str);
			var myDate = new Date(converted);
			if (isNaN(myDate)) {
				if (str.indexOf(":") != -1) {
					str = str.replace(" ", "-");
					str = str.replace(":", "-");
					str = str.replace(":", "-"); // 第二个时间
					var arys = str.split('-');
					myDate = new Date(arys[0], --arys[1], arys[2], _this.isNull(arys[3], 0), 
                    _this.isNull(arys[4], 0), _this.isNull(arys[5], 0));
				} else {
					var arys = str.split('-');
					myDate = new Date(arys[0], --arys[1], arys[2]);
				}
			}
			return myDate;
		},
        var strTime = '2017-12-07 16:59:55.0'; 
        var dateTime = strToDate(strTime);
        var timeValue = Date.parse(dateTime);
        console.log('至该时间的毫秒值:' + timeValue);




 

转载于:https://my.oschina.net/u/3125215/blog/1586453

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值