Javascript setting Date to previous year from the current year [closed]
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);
精彩评论