This free plugin, by Robin Brayer from Interactive Tools is for all of you who would rather see “Saturday, April 30, 2011" instead of “2011-04-30 09:44:46" for dates that are displayed in your records list view.
Just copy the code below and paste it into a blank PHP document, save it as listViewDateFormat.php and upload it to your cmsAdmin/plugins folder. Then in the admin section, under plugins, activate your new plugin.
You can customize exactly how your date displays by changing the line $dateFormat = "l, F, d, Y"; in the plugin, following the guide in the Cookbook recipe called SHOW DATES ON YOUR PAGE
<?php
// register hooks addFilter('listRow_displayValue', '_lvdf_changeDateFormat', null, 4);
function _lvdf_changeDateFormat($displayValue, $tableName, $fieldname, $record) {
$returnValue = $displayValue;
//Should we even consider this field? if(!($displayValueTimeStamp = @strtotime($displayValue))) { return $returnValue; }
// Determines the display format of the date field $dateFormat = "l, F, d, Y";
$year = substr($displayValue, 0, 4); $firstHyphen = substr($displayValue, 4, 1);
$month = substr($displayValue, 5, 2); $secondHyphen = substr($displayValue, 7, 1);
$day = substr($displayValue, 8, 2);
//echo $year . " " . $firstHyphen . " " . $month . " " . $secondHyphen . " " . $day;
if(is_numeric($year) && is_numeric($month) && is_numeric($day) && ($firstHyphen == "-") && ($secondHyphen == "-")) { $displayValueTimeStamp = strtotime($displayValue); if($displayValueTimeStamp > 1) { $returnValue = date($dateFormat, $displayValueTimeStamp); } } return $returnValue; }
?>
|