admin管理员组文章数量:1425995
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
Microsoft JScript runtime error: Object doesn't support property or method 'getFullYear'
What is the problem..please help Thanks
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
Microsoft JScript runtime error: Object doesn't support property or method 'getFullYear'
What is the problem..please help Thanks
Share Improve this question edited Jan 25, 2012 at 12:42 James Jithin 10.6k6 gold badges40 silver badges52 bronze badges asked Jan 25, 2012 at 12:37 user1025901user1025901 1,9094 gold badges22 silver badges28 bronze badges 2- fromDate is string not date object to support getFullYear function – Sudesh Commented Jan 25, 2012 at 12:39
-
When it's a Date object it works just fine - if this still fails it means the machine running this code has different regional settings, for example yyyy-mm-dd in which case correct string would be
2012-01-17
. – user447356 Commented Jan 25, 2012 at 12:47
1 Answer
Reset to default 4The problem is that you have a string, and treat it likt it was a Date
object.
Create a Date
object:
var fromDate = new Date(2012, 0, 17);
or parse a string:
var fromDate = Date.parse('2012-01-17');
本文标签: internet explorer 9Javascript getFullYear function is not working in IE 9Stack Overflow
版权声明:本文标题:internet explorer 9 - Javascript getFullYear function is not working in IE 9 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745357227a2655126.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论