PHP:从1969年开始获取周数
我需要得到1969年开始的实际周数,如下所示:PHP:从1969年开始获取周数,php,date,Php,Date,我需要得到1969年开始的实际周数,如下所示: $dateTime = new DateTime; $now = '2017-01-01'; // // $week = date('W', strtotime($now . ' +2 days')); // I will get the week number between 01-53 and this is not what I want. // I need to set the starting year and get the we
$dateTime = new DateTime;
$now = '2017-01-01';
//
// $week = date('W', strtotime($now . ' +2 days'));
// I will get the week number between 01-53 and this is not what I want.
// I need to set the starting year and get the week number since 1969 to get the expected results.
// How to get the value 2506 from this $week variable?
//
$dateTime->setISODate('1969', 2506, -1);
$start_by = $dateTime->format('Y-m-d');
// output: 2016-12-31
如您所见,“2016-12-31”是我每周开始的日期时间
提前谢谢你 似乎很简单
<?php
$date1 = new DateTime();
$date2 = new DateTime("1969-01-21");
$interval = $date1->diff($date2);
echo ceil($interval->days / 7);
?>
看起来很简单
<?php
$date1 = new DateTime();
$date2 = new DateTime("1969-01-21");
$interval = $date1->diff($date2);
echo ceil($interval->days / 7);
?>
实际的周数是多少?是本年度的周数吗?是不是从1969年起已经过去了几周?这是家庭作业吗?它是自1969年以来的周数获取当前周数,并将其乘以前几年的周数。就像现在的星期是23,那么23+(从1969年开始的年份*53)=一些值实际的星期数是多少?是本年度的周数吗?是不是从1969年起已经过去了几周?这是家庭作业吗?它是自1969年以来的周数获取当前周数,并将其乘以前几年的周数。就像现在的星期是23,然后是23+(从1969年开始的一年*53)=你救了我的命,伙计!你救了我的命,伙计!