2017-09-25 103 views
0

我有一個返回'1970-01-01'爲空值的日期字段。所以,我想創建一個三元運算符的變量$from .Still返回1970-01-01.What我做錯了變量的三元運算符

$from=$asset_other_details->start_date; //1970-01-01 
$from == '1970-01-01' ? '' : $from ; 
+0

檢查我給 – user3386779

+0

你不重新分配的確切文字'from' – msfoster

+0

做它的分配。 – chris85

回答

8

你必須基於像下面的比較輸出新的值賦給$form: -

$from = $asset_other_details->start_date; //1970-01-01 
$from = ($from == '1970-01-01') ? '' : $from ; 

輸出瞭解: - https://eval.in/867743

1

你不分配$from新的價值。請嘗試以下操作:

$from = ($asset_other_details->start_date == '1970-01-01') ? '' : $asset_other_details->start_date;