在IE 8中,日期是NaN / Nan / Nan [英] In IE 8 dates are NaN/Nan/Nan

查看:589
本文介绍了在IE 8中,日期是NaN / Nan / Nan的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IE8中,我的日期没有正确显示。我已经尝试了很多实现,但它们不能正常工作。这是我最初在FF,Chrome和IE9中的作品。

  var date = TranslateDate(new Date(CreatedDate); 

其中,CreatedDate是ac#日期时间对象。

 函数TranslateDate(d){
return GetMonth(d)+'/'+ GetDay(d)+'/'+ d.getFullYear();
}

函数GetMonth(d){
var month = d.getMonth()+1;
return((''+ month).length< 2?'0 ':'')+ month;
}

函数GetDay(d){
var day = d.getDate();
return((''+日).length< 2?'0':'')+ day;
}

任何帮助将不胜感激!

解决方案

到目前为止,最简单的解决方案是使用moment.js。文件,而不是基于IE 8的URL查找它。


In IE8 my dates are not appearing properly. I have tried many implementations but they are not working properly. Here is what I had originally that works in FF, Chrome and IE9.

var date = TranslateDate(new Date(CreatedDate);

where CreatedDate is a c# datetime object.

function TranslateDate(d) {
    return GetMonth(d) + '/' + GetDay(d) + '/' + d.getFullYear();
}

function GetMonth(d) {
    var month = d.getMonth() + 1;
    return (('' + month).length < 2 ? '0' : '') + month;
}

function GetDay(d) {
    var day = d.getDate();
    return (('' + day).length < 2 ? '0' : '') + day;
}

Any help would be appreciated!

解决方案

By far the easiest solution was to use moment.js. Make sure you save the file instead of looking it up based on a url for IE 8.

这篇关于在IE 8中,日期是NaN / Nan / Nan的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆