Page 1 of 1

Timestamp Formatting

PostPosted: Wed Sep 30, 2009 10:36 pm
by dbaron2
I am trying to format a timestamp field using the %fieldname%__display delegate class, but the procedure is getting ignored. What am I missing?

function last_updated__display(&$record){
if ($record->val('last_updated') == NULL){
return "";
} else {
return date('Y-m-d H:i:s', strtotime($record->strval('last_updated')));
}
}

[last_updated]
widget:label = "Last Updated"
widget:type = static
visibility:list = hidden
visibility:browse = hidden
order = 13

`last_updated` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,

PostPosted: Wed Sep 30, 2009 11:38 pm
by Jean
You need $element

Code: Select all
function last_updated__display(&$record, $element)


Jean

PostPosted: Thu Oct 01, 2009 12:02 am
by dbaron2
Thanks for pointing me in the right direction. I ended up getting it to work with the following:

function last_updated__pullValue(&$record, $element){
if ($record->val('last_updated') == NULL){
return "";
} else {
return date('Y-m-d H:i:s', strtotime($record->strval('last_updated')));
}
}