Reputation: 2097
The following code is the output into a table where I have a list of dates which are also hyperlinks to an event on that date. It currently displays YMD and I would like it to display DMY.
I have tried using 'dateFormat'=>'DMY' in the array but this does not change anything.
Html->link($shiftsession['Shiftsession']['sessionDate'], array( 'controller' => 'shiftsessions', 'action' => 'view', $shiftsession['Shiftsession']['SessionID'])); ?>
http://book.cakephp.org/1.2/view/203/options-dateFormat
If anyone could shed some light on how you properly use dateFormat I'd be stoked.
Upvotes: 0
Views: 482
Reputation: 29121
Good ole' PHP date() to the rescue:
<?php
//use PHP's date() to format the date in any way you'd like
$theDate = date('DMY', strtotime($shiftsession['Shiftsession']['sessionDate']));
//build the link using the newly formatted date
$this->Html->link($theDate, array(
'controller' => 'shiftsessions',
'action' => 'view',
$shiftsession['Shiftsession']['SessionID']
));
(Obviously you could write that whole thing into one line... for example purposes on StackOverflow, it reads better like this imo)
With CakePHP:
CakePHP has a nice Time Helper, but it doesn't have an option to specify exactly what format you'd like. Instead, it has things like gmt()
, and niceShort()
, and timeAgo()
...etc
Upvotes: 1