脚本宝典收集整理的这篇文章主要介绍了php – 从当天开始接下来的6天?,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<?PHP $weekOfdays = array(); $day = date('l'); $weekOfdays[] = $day; $day = strtotime($day); $next = strtotime("+6 day",$day); $weekOfdays[] = date("l",$next); var_dump($weekOfdays); // output // array (size=2) // 0 => string 'Monday' (length=6) // 1 => string 'Sunday' (length=6) ?>
我想看到阵列是这样的
array (size=7) 0 => string 'Monday' (length=6) 1 => string 'Tuesday' (length=7) 2 => string 'Wednesday' (length=9) 3 => string 'Thursday' (length=8) 4 => string 'Friday' (length=6) 5 => string 'Saturday' (length=8) 6 => string 'Sunday' (length=6)
$days = []; $PEriod = new DatePeriod( new DateTime(),// Start date of the period new Dateinterval('P1D'),// define the intervals as Periods of 1 Day 6 // Apply the interval 6 times on top of the starting date ); foreach ($period as $day) { $days[] = $day->format('l'); }
以上是脚本宝典为你收集整理的php – 从当天开始接下来的6天?全部内容,希望文章能够帮你解决php – 从当天开始接下来的6天?所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。