Cakephp 更改日期格式
我有以下显示所有呼叫详细信息的代码,我希望“call_date”的日期格式更改为“dd-mm-yyyy”,并且我的calls/index.ctp中有以下代码:Cakephp 更改日期格式,cakephp,format,Cakephp,Format,我有以下显示所有呼叫详细信息的代码,我希望“call_date”的日期格式更改为“dd-mm-yyyy”,并且我的calls/index.ctp中有以下代码: <div class="callsIndex"> <h2><?php echo __('Call Details'); ?> </h2> <div class="bottomButtonnew"><?php echo $this->Html->
<div class="callsIndex">
<h2><?php echo __('Call Details'); ?> </h2>
<div class="bottomButtonnew"><?php echo $this->Html->link(__('Add Calls'), array('action' => 'add')); ?></div>
<table cellpadding="0" cellspacing="0">
<tr>
<th><?php echo $this->Paginator->sort('Call Date'); ?></th>
<th><?php echo $this->Paginator->sort('Call Time'); ?></th>
<th><?php echo $this->Paginator->sort('Comments'); ?></th>
<th><?php echo $this->Paginator->sort('Next Call Date'); ?></th>
<th><?php echo $this->Paginator->sort('Customer Name'); ?></th>
<th><?php echo $this->Paginator->sort('Company Name'); ?></th>
<th><?php echo $this->Paginator->sort('Employee Name'); ?></th>
<th class="actions"><?php echo __(''); ?></th>
</tr>
<?php foreach ($calls as $call): ?>
<tr>
<td><?php echo h($call['Call']['call_date']); ?> </td>
<td><?php echo h($call['Call']['call_time']); ?> </td>
<td><?php echo h($call['Call']['comments']); ?> </td>
<td><?php echo h($call['Call']['next_call_date']); ?> </td>
<td>
<?php echo $this->Html->link($call['Customers']['customer_name'], array('controller' => 'customers', 'action' => 'view', $call['Customers']['id'])); ?>
</td>
<td>
<?php echo $this->Html->link($call['Companies']['company_name'], array('controller' => 'companies', 'action' => 'view', $call['Companies']['id'])); ?>
</td>
<td>
<?php echo $this->Html->link($call['Employees']['employee_name'], array('controller' => 'employees', 'action' => 'view', $call['Employees']['id'])); ?>
</td>
<td class="actions">
<?php echo $this->Html->link(__('View'), array('action' => 'view', $call['Call']['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<p>
<?php
echo $this->Paginator->counter(array(
'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total')
));
?> </p>
<div class="paging">
<?php
echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
echo $this->Paginator->numbers(array('separator' => ''));
echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
?>
</div>
<br>
</div>
如何将“通话日期”中的日期格式更改为dd mm yyyy?有人能帮忙吗?用这个
<td><?php echo date("d-m-Y", strtotime($call['Call']['call_date'])); ?> </td>
使用
date()
和strotime()
函数的替代方法(如前面的评论和@VishalSharma的回答中所述)是使用CakePHP附带的时间助手
该方法可以使用以下命令格式化日期/时间值:
您能告诉我当前通话日期的格式吗当前格式是“yyyy-mm-dd”@Vishal Sharmatry这个回音日期(“d-m-Y”,strotime($call['call']['call\u date'));这有帮助吗?还是你想让我把所有的代码都放在这里?
$this->Time->format($call['Call']['call_date'], '%d-%m-%Y')