Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

noblemfd's avatar

How to display None when date of birth is null

In my index.blade, I have this:

<h6 class="lead"><b>Hire Date: </b>{{ \Carbon\Carbon::parse($employee->hire_date)->format('d-m-Y') }} </h6>

But I observed that when hire_date is not available, it displays the current date.

How do I display None or Null when the hire_date is not available instead of the current date?

Thanks

0 likes
1 reply
a4ashraf's avatar
a4ashraf
Best Answer
Level 33

@noblemfd

try with this

<h6 class="lead"><b>Hire Date: </b>{{ $employee->hire_date ? \Carbon\Carbon::parse($employee->hire_date)->format('d-m-Y') : "" }} </h6>

Please or to participate in this conversation.