简体   繁体   English

使用DateJS显示当前月份的最后一个星期四

[英]Showing the last thursday of the current month with DateJS

I am trying to show the last thursday of the current month with DateJS , however this library doesn't really work for me. 我试图用DateJS来显示当月的最后一个星期四,但是这个库对我来说真的不起作用。 Could you please help me with the solution? 您能帮我解决问题吗?

You may want to use the moveToLastDayOfMonth() method as follows: 您可能要使用moveToLastDayOfMonth()方法,如下所示:

var lastThuOfThisMonth;

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

Just tried it in Firebug. 刚刚在Firebug中尝试过。 I also checked for last().sunday() since this month ends with a Sunday. 我还检查了last().sunday()因为这个月以星期日结束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM