jQuery UI,Calendar,查看给定的日期是否超过2年 [英] jQuery UI, Calendar, find out if date given is over 2 years old
本文介绍了jQuery UI,Calendar,查看给定的日期是否超过2年的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hay Guys,我使用jQuery UI系统中的沼泽标准日历。显示的结果(用户点击日期后)为MM / DD / YYYY。
我想检查此日期是否不超过2岁
即
说用户选择
01/27/2004
这应该说日期早于2年份。但
12/25/2008
$任何想法?
解决方案。b
$ b
<方案
$ b
应通过测试。
<方案
var selectedDate = new Date('01 / 27/2004');
selectedDate.setFullYear(chosenDate.getFullYear()+ 2);
var moreThan2YearsOld = selectedDate< new Date();
Hay Guys, I'm using the bog standard Calendar from the jQuery UI system. The result shown (after a user clicks a date) is MM/DD/YYYY.
I want to check that this date is not old than 2 years old
ie
say a user picks
01/27/2004
this should say that the date is older than 2 years. However,
12/25/2008
should pass the test.
any ideas?
解决方案
var selectedDate = new Date('01/27/2004');
selectedDate.setFullYear(selectedDate.getFullYear()+2);
var moreThan2YearsOld = selectedDate < new Date();
这篇关于jQuery UI,Calendar,查看给定的日期是否超过2年的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文