Php - 从几天到几周/天

Dar*_*ney 2 php algorithm

我将来有几天约会,但想知道它有多少个星期和几天.另外,注意到如果它不到一周,那么它只返回相同的数字.

这可能吗?

例如17天将是2周和3天

例如4天将是4天

joh*_*ohn 7

我会尝试这样的事情:

$days = 17;
$weeks = floor($days / 7);
$dayRemainder = $days % 7;
echo $days.'<br/>'.$weeks.'<br/>'.$dayRemainder;//add whatever logic you need here to get the display the way you want it.
Run Code Online (Sandbox Code Playgroud)