如何确定今天是否是PHP中每个月的第二个星期四


How to determine if today is the second thursday of each month in PHP?

如何确定今天是否是PHP中每个月的第二个星期四?

这是我想的,但似乎不起作用。

if (date('d', strtotime('second thursday')))

这将与本月第二个星期四的日期相呼应:

<?php
echo date('d', strtotime('second thursday of this month'));
// Will echo 10, which is correct for april 2014
echo date('d', strtotime('second thursday of next month'));
// Will echo 08, which is correct for may 2014
echo date('d', strtotime('second thursday of previous month'));
// Will echo 13, which is correct for march 2014

针对您的问题的If声明:

<?php
if (date('d') == date('d', strtotime('second thursday of this month'))) {
    echo 'Second thursday!';
} else {
    echo 'Not the second thursday';
}