从2016年3月3日开始每隔三个星期四回音

Aro*_*ron 3 php wordpress

我正在使用wordpress为公司开发一个网站

从2016年3月3日起,他们每三个星期四举行一次董事会会议

我试图创建一个短代码

我希望在下次会议召开时回应.

这是我到目前为止所得到的,但这不正确.

// ECHO next board_meeting - Use [next_board_meeting]
add_shortcode( 'next_board_meeting', 'next_board_meeting_shortcode' );
function next_board_meeting_shortcode( $str ) {

echo date_i18n('l j F', strtotime('next thursday +2 week'));

}
Run Code Online (Sandbox Code Playgroud)

我一直在网上搜索这样的东西,但我在这里,请求你的帮助.

有一个简单的方法来做到这一点,还是我需要创建一个复杂的PHP脚本?

请记住,我刚刚学会了如何在php中完成简单的任务.

Pra*_*Rao 7

此代码将为您提供当月的第三个星期四..

如果当前日期已经过了第四个周四那么它将显示下个月的第四个周四..如果当前月份是12月并且已经过了第三个周四那么它将在明年1月的第四个周四显示

<?php
$current_date = strtotime(date("d.m.Y"));

//$final = date("Y-m-d", strtotime("+1 month", $time));

$FullMonth = date('F',$current_date);
$FullYear = date('Y',$current_date);
$Third_Thus = date('d F Y', strtotime('third thursday of '.$FullMonth.' '.$FullYear));
$ThirdThus_tmstamp = strtotime($Third_Thus);
if($current_date <= $ThirdThus_tmstamp){
    echo date('d F Y', strtotime('third thursday of '.$FullMonth.' '.$FullYear));
}
else{
    if($FullMonth != 'December'){
        $FullMonth = date('F',strtotime("+1 month", $current_date));
        $FullYear = date('Y',$current_date);
    } else{
        $Next_Year = strtotime("+1 year", $current_date);
        $FullYear = date('Y',$Next_Year);
        $FullMonth = date('F',strtotime("+1 month", $Next_Year));
    }
    echo date('d F Y', strtotime('third thursday of '.$FullMonth.' '.$FullYear));
}?>
Run Code Online (Sandbox Code Playgroud)

这将显示当前月或下个月的第三个周四,具体取决于当前日期..如果您想要下一个2-3个月的第3个周四,那么您现在可以进行一些更改!