[英]Javascript getFullYear function is not working in IE 9
If I do 如果我做
function test()
{
var fromDate="01/17/2012";
var res= Test1(fromDate);
return false;
}
function Test1(d1) {
alert(d1.getFullYear());
}
It is failing at d1.getFullYear() with the message 它在d1.getFullYear()中失败,并显示以下消息
Microsoft JScript runtime error: Object doesn't support property or method 'getFullYear' Microsoft JScript运行时错误:对象不支持属性或方法“ getFullYear”
What is the problem..please help Thanks 有什么问题..请帮助谢谢
The problem is that you have a string, and treat it likt it was a Date
object. 问题是您有一个字符串,并且将其视为
Date
对象对待。
Create a Date
object: 创建一个
Date
对象:
var fromDate = new Date(2012, 0, 17);
or parse a string: 或解析一个字符串:
var fromDate = Date.parse('2012-01-17');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.