cakephp - CAKE PHP 更改日期格式

标签 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->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']); ?>&nbsp;</td>
                <td><?php echo h($call['Call']['call_time']); ?>&nbsp;</td>
                <td><?php echo h($call['Call']['comments']); ?>&nbsp;</td>
                <td><?php echo h($call['Call']['next_call_date']); ?>&nbsp;</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>

如何将“call_date”中的日期格式更改为 dd-mm-yyyy?有人可以帮忙吗?

最佳答案

用这个

 <td><?php echo date("d-m-Y", strtotime($call['Call']['call_date'])); ?>&nbsp;</td>

关于cakephp - CAKE PHP 更改日期格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23821286/

相关文章:

php - CakePHP自定义setFlash

timestamp - 理解 'event_timestamp' 数字

printing - Prolog - 使用 format/2 打印列表列表

php - 缺少数据库表 - CakePHP

postgresql - 修改cakephp中的Routes.php文件

php - cakephp 3.2.3 日期查询不起作用

c# - 如何在 wpf (DataGrid) 中格式化 TimeSpan?

c# - foreach 循环中的 String.Format 用于在同一行中打印

python - 可用于日志格式的调用堆栈

是否使用PHP框架(Cake PHP)