usng finc condition i am getting following result. I want to change the my timestamp to date format . while using find condition .
for example :- $emailLogDetail= $this->LogEmail->find('all', array(
'fields' => array(
'LogEmail.*',
//'date("m/d/Y", strtotime(LogEmail.TimeStamp)) as Date',
'User.email'
),
'order' => 'LogEmail.id DESC',
'joins' => $joins
));
现在我已经评论了日期转换代码,因为它给出了错误。 但是有没有办法在添加选择查询时将时间戳转换为日期
Array
(
[0] => Array
(
[LogEmail] => Array
(
[Id] => 12
[Status] => sent
[UserId] => 42
[Subject] => Confirmation!
[Body] => hiiiii
[TimeStamp] => 1395912288
[ActionName] => Register
)
[User] => Array
(
[email] => test@gmail.com
)
)
)
使用这个
"FROM_UNIXTIME(LogEmail.TimeStamp) as date"
带格式化
"FROM_UNIXTIME(LogEmail.TimeStamp, '%m%d%y') as date"
您要求将该格式化样式存储在核心上.php并在整个应用程序上使用它。我建议你不要采取这种方法...在这里--
核心.php
Configure::write('dateFormat',"FROM_UNIXTIME(LogEmail.TimeStamp, '%m\%d\%y') as date");
现在,您可以从应用程序的任何位置读取此内容,例如-
$dateFormat = Configure::read('dateFormat');
$emailLogDetail= $this->LogEmail->find('all', array(
'fields' => array(
'LogEmail.*',
$dateFormat,
'User.email'
),
'order' => 'LogEmail.id DESC',
'joins' => $joins
));