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

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – 从2016年3月3日开始每三个星期四回音脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用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'));

}

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

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

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

解决方法

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

如果当前日期已经过了第四个周四那么它将显示下个月的第四个周四..如果当前月份是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',$current_date));
        $FullYear = date('Y',$current_date);
    } else{
        $Next_Year = strtotime("+1 year",$current_date);
        $FullYear = date('Y',$Next_Year);
        $FullMonth = date('F',$Next_Year));
    }
    echo date('d F Y',strtotime('third thursday of '.$FullMonth.' '.$FullYear));
}?>

脚本宝典总结

以上是脚本宝典为你收集整理的php – 从2016年3月3日开始每三个星期四回音全部内容,希望文章能够帮你解决php – 从2016年3月3日开始每三个星期四回音所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。