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

batotanete's avatar

How not to show automatic date 01 January 1970, if the date value is null

If I have code like this:

<td>{{date('d F Y', strtotime($item->expire))}}</td>

If "$item->expire" worth "Null" then the result will automatically be: 01 January 1970

How to fix it not showing or can it be replaced with a string value (eg "-")?

0 likes
3 replies
SilenceBringer's avatar
Level 55
<td>{{ $item->expire ? date('d F Y', strtotime($item->expire)) : '' }}</td>
bait-dept's avatar

If you need to perform that everywhere for the items,look for accessors.

1 like

Please or to participate in this conversation.