php中月份以星期为单位,PHP的月份第二个星期六
我发现这个PHP代码
credit to creator并希望以不同的方式实现它:
目标是让代码自动将以下语句调整为从现在起到永恒的每个月的第二个星期六:
下次会员会议:周六,每年,每年,上午11点至中午.
如:“2011年2月12日星期六,上午11点到中午.”
我不是PHP大师,有人可以编辑它来工作吗?
function nextMeeting($nextMonth = false) {
$day=date("j");
$month=date("n");
$year=date("Y");
if ($nextMonth) {
$day=1;
if ($month == 12) {
$month=1;
$year++;
} else {
$month++;
}
}
$dayofweek=date("w");
$firstOfMonth=date("w",mktime(0, 0, 0, $month , 1, $year ));
// figure out what date is the second Saturday of the month
if ( $firstOfMonth > 0 ) {
$firstSunday= 8 - $firstOfMonth;
} else {
$firstSunday= 1;
}
$firstSundayDate=date("D",mktime(0, 0, 0, $month ,
$firstSunday, $year));
// figure out what date the third monday of the month is
if ( $firstOfMonth > 1) {
$offSet = 8 - $firstOfMonth;
} elseif ( $firstOfMonth == 0 ) {
$offSet=1;
} else {
$offSet=0;
}
$thirdMonday= 15 + $offSet;
$thirdMondayDate=date("D",mktime(0, 0, 0, $month ,
$thirdMonday, $year));
// lets see which of these dates now applies
if ($day <= $firstSunday) {
// we didn't miss the first meeting
$nextMeeting=$firstSunday;
$nextMeetingDate=mktime(0, 0, 0, $month ,
$nextMeeting, $year);
} elseif ( ($day > $firstSunday) && ($day <= $thirdMonday) ) {
// we missed the first meeting of the month, but can still make the second
$nextMeeting=$thirdMonday;
$nextMeetingDate=mktime(0, 0, 0, $month ,
$nextMeeting, $year);
} else {
// we need to wait until next month
$nextMeetingDate=nextMeeting(1);
$nextMeeting=nextMeeting(1);
}
return $nextMeetingDate;
}
$meeting=nextMeeting();
echo "Next membership meeting is on " . date('l dS \of F Y', $meeting);
?>
php中月份以星期为单位,PHP的月份第二个星期六相关推荐
- 航空票务中的月份和星期缩写
航空票务中的月份和星期缩写 JAN 一月 FEB 二月 MAR 三月 APR 四月 MAY 五月 JUN 六月 JUL 七月 AUG 八月 SEP 九月 OCT 十月 NOV 十一月 DEC 十二月 ...
- 月份加日期前面用on还是in_英语句子日期、月份和星期前面各应该加in还是on?如题.可以的话,帮...-星期前面用on还是in-英语-郑谒牡同学...
概述:本道作业题是郑谒牡同学的课后练习,分享的知识点是星期前面用on还是in,指导老师为农老师,涉及到的知识点涵盖:英语句子日期.月份和星期前面各应该加in还是on?如题.可以的话,帮...-星期前面 ...
- 关于ArcMap中的地图文档单位
在ArcMap中地图文档的单位有度分秒.千米.米.十进制等很多种,但是ArcMap中的测量距离功能的实现必须建立在图层框架具有投影坐标系的情况下才能进行正确的计算,否则是不能进行的,IPolyline ...
- JAVA日期查询:季度、月份、星期等时间信息
参考:JAVA日期查询:季度.月份.星期等时间信息 import java.util.Calendar;public class Date {Calendar calendar = null;publ ...
- Excel中如何快速汇总带单位的数据
Excel中如何快速汇总带单位的数据 目录 Excel中如何快速汇总带单位的数据 1.例如快速求下表总销售量 2.张华总销售量手动输入"A=23+300+123+45",其他人员总 ...
- min-width、max-width属性中min-content、max-content的含义,css中minmax()用法、1fr单位的含义----使页面具有相应性的属性以及属性值
min-width.max-width属性中min-content.max-content的含义,css中minmax()用法.1fr单位的含义 min-width 表示容器的最小宽度 max-wid ...
- 微信小程序中的vw和vh单位
微信小程序中的vw和vh单位 100vw代表手机宽度, 100vh代表手机高度. 实现代码: button{width: 50vw;}
- 计算机中存储数据最小的单位是什么,计算机中存储数据的最小单位和存储容量的基本单位各是什么?...
pb呢计算机中存储数据的最小单位:位bit(比特)(BinaryDigits),存放一位二进制数,即0或1,最小的存储单位.存储容量的基本单位是:bit.B.KB.MB.GB.TB.PB.EB.ZB. ...
- python中time库的时间单位是秒
相信学过C语言的同学应该都知道,C语言time库的时间单位是毫秒. 作为一个Python小白,在接触Python的time库时,我竟下意识的以为Python的time库时间单位也是毫秒,于是出现了之后 ...
最新文章
- 我非要捅穿这 Neutron(四)Open vSwitch in Neutron
- 阿里巴巴启动2017全球创客大赛 四大洲共设25个赛区
- vsftp账号_Linux入门-CentOS7安装vsftp
- 第十五章 Python和Web
- eclipse 错误: 找不到或无法加载主类
- PMP读书笔记(第4章)
- 传动系统结构简图_立式砂磨机与卧式砂磨机的结构特点比较
- 050、JVM实战总结:动手实验:使用 jstat 摸清线上系统的JVM运行状况
- Android SharedPreference最佳实践
- hdu 1254 推箱子(嵌套搜索,bfs中有dfs)
- 线性代数学习之行列式
- php 到处excel 乱码,php导出Excel乱码怎么解决?
- 【icourse163】学习python爬虫的代码整理
- LM358运放(比较器、跟随器)输出最高电压问题的探讨
- 使用Python读取Windows注册表
- KIS迷你版软件用户常见问题
- 2017282110258--高级软件工程--齐爽爽第一次作业
- ym——Android从零开始(27)(山寨版微信-上)(新)
- 微型计算机百度云,STONE_百度云资源_盘多多如风搜_盘搜搜_哎哟喂啊
- React AntV/G2Plot环形图Pie添加点击事件,即点击图环触发获取相关数据。