English 中文(简体)
对象函数 Date() {{[本地代码]}} 没有方法比较 日期。 js in Chrome
原标题:Object function Date() { [native code] } has no method compareTo when use Date.js in Chrome

我有两个日期时间变数 写在 Javascript 上:

first_date = Date.parse( 05/21/2012 0:00:00  );
second_date = Date.today();

如果我使用(http://code.google.com/p/datejs/wiki/APIDocumentation#compare To )

return first_date.compareTo(second_date)

然后出现例外 :

Object 函数 Date () {[本地代码]} 没有方法比对到 Google Chrome 中的

我使用http://www.datejs.com/" rel="nofollow">http://www.datejs.com/。

如何解决这个问题?

我要提到,其他职能(添加(-5).days(),今天()等)运作良好。

PS:我在这里查看了一下(http://code.google.com/p/datejs/issues/detail?id=129 ),但没有变通办法。

最佳回答

first_date >和 是符合您的代码的字符串,而 date.compare 甚至不存在,除非您使用 >svn-trunk 版本

datejs 定义了 Date. prototype.compare to 这样您只能使用 date_obj_a.compareTo(...)

问题回答
first_date = Date.parse( 05/21/2012 0:00:00  );
second_date = Date.today();

console.log(first_date.compareTo(second_date)); // just working fine




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.