admin管理员组文章数量:1406063
i have the date in a string format like so '11/2/2009'
(m/d/yyyy)
I need to test if that is greater than 30 days ago.
Whats the easiest and least error-prone way to do this.
i have the date in a string format like so '11/2/2009'
(m/d/yyyy)
I need to test if that is greater than 30 days ago.
Whats the easiest and least error-prone way to do this.
Share Improve this question asked Nov 2, 2009 at 22:00 Jon EricksonJon Erickson 115k45 gold badges139 silver badges178 bronze badges2 Answers
Reset to default 6Something like this perhaps:
var then = new Date("11/2/2009").getTime(),
now = new Date().getTime(),
thirtyDaysInMilliseconds = 2592000000;
if (now - then > thirtyDaysInMilliseconds) { doSomething(); }
You'll have to be sure your date meets the format (MM-DD-YYYY), but this should work:
var olddate = "11/02/2009"
var dt = Date.parse( olddate );
return ( ( Date.getTime() - dt.getTime() ) < 2592000000 );
本文标签: jqueryJavaScript test if date (in string format) is more than 30 days agoStack Overflow
版权声明:本文标题:jquery - JavaScript test if date (in string format) is more than 30 days ago - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744957530a2634448.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论