2017-09-25 11 views
0

空の値として '1970-01-01'を返す日付フィールドがあります。だから私は、変数$from .Stillのための三項演算子を作成したい、それは私が間違って変数の3進演算子

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

私はあなたがfrom' – user3386779

+0

を与えられた正確なテキストを確認してください。 – msfoster

+0

が割り当てでそれを行う '再割り当てしていない – chris85

答えて

8

をした1970-01-01.What返しますあなたは以下のような比較出力に基づいて$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; 
関連する問題