Timestamp Formatting

A place for users and developers of the Xataface to discuss and receive support.

Timestamp Formatting

Postby 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,
dbaron2
 
Posts: 15
Joined: Wed Sep 30, 2009 10:27 pm

Postby Jean » Wed Sep 30, 2009 11:38 pm

You need $element

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


Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Postby 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')));
}
}
dbaron2
 
Posts: 15
Joined: Wed Sep 30, 2009 10:27 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 11 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved