Timestamp Formatting
Archived from the Xataface Users forum.
dbaron2 — Wed Sep 30, 2009 10:36 pm
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,
Jean — Wed Sep 30, 2009 11:38 pm
You need $element
- Code: Select all
function last_updated__display(&$record, $element)
Jean
dbaron2 — Thu Oct 01, 2009 12:02 am
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’)));
}
}