Date Format in Edit List View

3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 22, 2010   (RSS)

Re: [newmediachoice] Date Format in Edit List View

By Jason - October 22, 2010

Hi,

Yes, you can do this by editing the file cmsAdmin/lib/menus/default/list_functions.php. This controls how the list view is displayed.

You need to find a function called:
function _getColumnDisplayValueAndAttributes($fieldname, &$record)

This is closer to the end of the page.

If you're using a date field that you have created yourself, you need to change this code:
// date fields
if(@$fieldSchema['type'] == 'date') {
if (@!$fieldSchema['showTime']) { $displayValue = date("Y-m-d", strtotime($record[$fieldname])); }
if (!$record[$fieldname] || $record[$fieldname] == '0000-00-00 00:00:00') { $displayValue = ''; }
}

to this:
// date fields
if(@$fieldSchema['type'] == 'date') {
if (@!$fieldSchema['showTime']) { $displayValue = date("d-m-Y", strtotime($record[$fieldname])); }
if (!$record[$fieldname] || $record[$fieldname] == '0000-00-00 00:00:00') { $displayValue = ''; }
}


If you're using the default createdDate field, you need to add some new code directly under the code above:

if($fieldname=="createdDate"){
$displayValue=date("d-m-Y",strtotime($record[$fieldname]));
}


Hope this helps. Let me know if you have any other questions.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Date Format in Edit List View

Hi Jason

Many thanks - worked a treat :) !