I'm trying to display the date in DMY format and database is stored as YMD format. how can I change into DMY format? If I've to use form helper how to I exactly use to display? This is my code for display.
<?php
$i = 0;
foreach ($jobtasks as $jobtask):
$class = null;
if ($i++ % 2 == 0) {
$class = ' class="altrow"';
}
?>
<table><tr>
<td><?php echo $jobtask['Jobtask']['date']; ?> </td>
</tr>
You can use the Time class:
At the beginning of your php file write:
use Cake\I18n\Time;
And when you want to print the date:
<?php
$time = new Time($jobtask['Jobtask']['date']);
echo $time->format('dd-MM-yyyy HH:mm:ss');
?>
尝试使用此代码为您工作。...以您需要的DMY格式存储日期字段时间...
<td><?php echo date('D M Y', strtotime($jobtask['Jobtask']['date'])); ?> </td>
you should be able to use the time helper: http://book.cakephp.org/view/1471/Formatting
nice(), niceShort() or just format()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.