在我看来,我有如下两个日期:
{{$property->start_date }} //which is for example 3/20/219
Run Code Online (Sandbox Code Playgroud)
和另一个日期
{{$property->end_date }} //which is for example 3/28/219
Run Code Online (Sandbox Code Playgroud)
现在我想知道如何将这 8 天的差异打印为 8 col-lg-1 ,就像下面的代码一样
@while($property->start_date <= $property->end_date)
//here i want to print dates in col-lg-1 i dont know how to access the day and if the while loop is working right or no
Run Code Online (Sandbox Code Playgroud)
我怎样才能在刀片中实现这一点,考虑到我在我看来正在这样做,并且在我看来这样做是否合理。
您可以使用CarbonPeriod来自Carbon
像这样的东西
$ranges = CarbonPeriod::create('2019-03-01', '2019-03-31');
Run Code Online (Sandbox Code Playgroud)
要打印每个日期,您可以使用循环
foreach ($ranges as $date) {
echo $date->format('Y-m-d');
}
Run Code Online (Sandbox Code Playgroud)
或者你也可以将其转换为数组
$dates = $ranges->toArray();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3894 次 |
| 最近记录: |