小编Chr*_*her的帖子

Laravel blade compare two date

I would like to compare 2 dates. So I create a condition like this in my template blade:

@if(\Carbon\Carbon::parse($contrat->date_facturation)->format('d/m/Y') < $dateNow)
    <td class="danger">
        {{ \Carbon\Carbon::parse($contrat->date_facturation)->format('d/m/Y') }}
    </td>
@else
    <td>
        {{ \Carbon\Carbon::parse($contrat->date_facturation)->format('d/m/Y') }}
    </td>
@endif
Run Code Online (Sandbox Code Playgroud)

My variable $dateNow has the same format on my value in $contract->date_facturation

Screenshot

It add a red background on the date 25/02/2018 while the date is not less than the variable $contract->date_facturation

Do you have any idea of ??the problem?

Thank you

laravel blade

3
推荐指数
1
解决办法
5261
查看次数

标签 统计

blade ×1

laravel ×1