获取此格式的周数:
$weeknumber = date('W', strtotime('10-02-2015'));
如何从本周编号开始日期。
答案 0 :(得分:0)
使用此
您需要像strtotime('10-02-2015'))
$date_string = "2012-10-18";
$weeknumber = date("W", strtotime($date_string));
//get the date from week number
$gendate = new DateTime();
$gendate->setISODate(2013,$weeknumber ,4); //year , week num , day
echo $gendate->format('d-m-Y'); //"prints" 26-12-2013
答案 1 :(得分:0)
你可以用这个
echo $weeknumber = date('W', strtotime('18-10-2012'));
$gendate = new DateTime();
$gendate->setISODate(2015,$weeknumber,4); //year , week num , day
echo $gendate->format('d-m-Y'); //"prints"
答案 2 :(得分:0)
请勿将strtotime()
和date()
函数与DateTime
类混合使用。它可以在没有它们的情况下完成,只有DateTime
,例如:
$date = new DateTime('10-02-2015');
$date->setISODate($date->format('o'), $date->format('W'));
echo $date->format('d-m-Y');