Reputation: 7175
I have a date field which returns '1970-01-01' for empty value. So I want to create a ternary operator for a variable $from
.Still it returns 1970-01-01.What I did wrong
$from=$asset_other_details->start_date; //1970-01-01
$from == '1970-01-01' ? '' : $from ;
Upvotes: 0
Views: 333
Reputation: 72299
You have to assign new values to $form
based on the comparison output like below:-
$from = $asset_other_details->start_date; //1970-01-01
$from = ($from == '1970-01-01') ? '' : $from ;
Output to understand:- https://eval.in/867743
Upvotes: 8
Reputation: 9396
you are not assigning the $from
the new value. Try the following:
$from = ($asset_other_details->start_date == '1970-01-01') ? '' : $asset_other_details->start_date;
Upvotes: 1