admin管理员组文章数量:1326118
I have these two date time variables in javascript:
first_date = Date.parse('05/21/2012 0:00:00 ');
second_date = Date.today();
If I'm using ( )
return first_datepareTo(second_date)
then exception occurs:
Object function Date() { [native code] } has no method 'pareTo'
in Google Chrome.
I'm using latest version of Date.js from /
How to solve this issue ?
I will mention that other functions (add(-5).days(), today(), etc.) works fine.
PS: I took a look here ( ) but no workaround.
I have these two date time variables in javascript:
first_date = Date.parse('05/21/2012 0:00:00 ');
second_date = Date.today();
If I'm using ( http://code.google./p/datejs/wiki/APIDocumentation#pareTo )
return first_date.pareTo(second_date)
then exception occurs:
Object function Date() { [native code] } has no method 'pareTo'
in Google Chrome.
I'm using latest version of Date.js from http://www.datejs./
How to solve this issue ?
I will mention that other functions (add(-5).days(), today(), etc.) works fine.
PS: I took a look here ( http://code.google./p/datejs/issues/detail?id=129 ) but no workaround.
Share Improve this question edited May 25, 2012 at 6:32 Snake Eyes asked May 25, 2012 at 6:15 Snake EyesSnake Eyes 16.8k39 gold badges118 silver badges232 bronze badges 1-
first_date
isn't a Date, it's a string, so that would explain why it doesn't have apareTo
method. You mention Chrome several times - does that imply your code does work in other browsers, or that you haven't tested in other browsers? The latest version of date.js that I downloaded didn't seem to define apare
method, justpareTo
. – nnnnnn Commented May 25, 2012 at 6:20
2 Answers
Reset to default 5first_date
and second_date
are strings according to your code and Date.pare
does not even exist unless you are using the svn-trunk version.
datejs defines Date.prototype.pareTo
so you can only use date_obj_a.pareTo(...)
.
first_date = Date.parse('05/21/2012 0:00:00 ');
second_date = Date.today();
console.log(first_date.pareTo(second_date)); // just working fine
本文标签:
版权声明:本文标题:javascript - Object function Date() { [native code] } has no method 'compareTo' when use Date.js in Chrome - Sta 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742192241a2430427.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论