【问题标题】:how to get first and last day of the week in a given month using php [duplicate]如何使用php获取给定月份中一周的第一天和最后一天[重复]
【发布时间】:2015-05-22 12:19:35
【问题描述】:

如何使用 php 获取给定月份中一周的第一天和最后一天。我试图通过谷歌搜索得到答案,但无法得到它。请帮助我任何身体。我将成为他的 gr8。

【问题讨论】:

标签: php


【解决方案1】:

大家好,我是如何得到解决方案的,下面给出。

$fstSunday = date("d-F-Y", strtotime("".date('M')." ".date('Y')."")); $weekArray = getfstlastdayOfWeekofmonth($fstSunday); 回声'

'; print_r($weekArray); function getfstlastdayOfWeekofmonth($paramFstSundayofMonth) { $fstSunday = $paramFstSundayofMonth; //echo 'last date of the week-'.$oneWeekLater = date('d-m-Y', strtotime('+1 week',strtotime($fstSunday))); $countMnth = date("t",strtotime($fstSunday)); $dayOfmonth = date("d",strtotime($fstSunday)); if($countMnth==31 && $dayOfmonth <= 3) $countmonth = 5; else $countmonth = 4; $weekArray = array(); for($i=0;$i<$countmonth;$i++) { $oneWeekLater = date('d-F-Y', strtotime('+1 week',strtotime($fstSunday)-1)); $weekArray[] = array('fstdayWeekOfmonth'=> $fstSunday,'lastDayWeekOfmonth'=>$oneWeekLater) ; $fstSunday = date('d-F-Y', strtotime('+1 week',strtotime($fstSunday))); } // echo '<pre>'; return $weekArray; }

【讨论】:

    猜你喜欢
    • 2011-11-24
    • 2016-01-13
    • 2014-11-21
    • 1970-01-01
    • 2015-06-26
    • 2023-03-30
    • 1970-01-01
    • 2013-11-25
    • 1970-01-01
    相关资源
    最近更新 更多