开发者

Javascript setting Date to previous year from the current year [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

i want to show jquery calendar dates from 1st september 2010 to current date.

for example

consider if i am spooling a report on 12th january 2011 ,i should allow jquery calendar selection from 1st september 2010 to 12th janyary 2011 .My question is how to set the date to 1st sep 2010 from current date (if current date is january 11th 2011) i.e next year. I want to get the date from the server and set in the javascript.

Currently i get the minimum date from serverside java like this

minDate = new Date();                           // timestamp now
Calendar cal = Calendar.getInstance();          // get calendar instance
cal.setTime(minDate);                           // set cal to date
cal.set(2010,cal.SEPTEMBER,1);
minDat开发者_高级运维e = cal.getTime();

the output would be 20100901

but i dont want to hardcode 2010 in the code , i want a generic code that takes 1st sep 2010 as minimum even when i execute on january 2011.


Use this:

int year = cal.get(Calendar.YEAR);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜