php – 从2016年3月3日开始每三个星期四回音
发布时间:2020-12-13 21:55:30 所属栏目:PHP教程 来源:网络整理
导读:我正在使用wordpress为公司开发一个网站 从2016年3月3日起,他们每三个星期四举行一次董事会会议 我试图创建一个短代码 我希望在下次会议召开时回应. 这是我到目前为止所得到的,但这不正确. // ECHO next board_meeting - Use [next_board_meeting]add_shortc
我正在使用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)); }?>
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |