T
T
Tarasovych2017-04-16 16:09:27
Laravel
Tarasovych, 2017-04-16 16:09:27

Why does Carbon return the current time if it is NULL in the database?

I get the publication time:

{{ \Carbon\Carbon::parse($blog->published_at)->format('d.m.Y H:i')}}

If it is NULL in the database, the current time is displayed. How to display an empty field instead of the current date?
Should I parseuse another method instead?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
pantagruel964, 2017-04-16
@Tarasovych

$date ? $date : ''

4
4iloveg, 2017-04-16
@4iloveg

Maybe the time() function is used which, without parameters, displays the current time. Or another function with similar behavior.
Wrap in a condition what to display, only if the date value is not null.
Or go to the carbon class and see how it is implemented there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question