views:

53

answers:

1

I am trying to show the last thursday of the current month with DateJS, however this library doesn't really work for me. Could you please help me with the solution?

A: 

You may want to use the moveToLastDayOfMonth() method as follows:

var lastThuOfThisMonth;

Date.today().moveToLastDayOfMonth().last().is().thursday() ? 
   lastThuOfThisMonth = Date.today().moveToLastDayOfMonth().last() :
   lastThuOfThisMonth = Date.today().moveToLastDayOfMonth().last().thursday();

Just tried it in Firebug. I also checked for last().sunday() since this month ends with a Sunday.

Daniel Vassallo