2017-09-25 105 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;