french format for dates

Archived from the Xataface Users forum.

cbovio — Mon Mar 05, 2007 1:41 am

i’m testing dataface, great job !

my first problem is date format : how can i have format dd/mm/YYYY in lists, views and editions with calendar assistant ?

thanks,


shannah — Mon Mar 05, 2007 12:30 pm

You can override the display of any field using delegate classes. E.g. if you have a column named “start_date” that is a datetime field. You can override how it is displayed with a function named start_date__display(). E.g.

Code: Select all
function start_date__display(&$record){     return date('d/m/Y', strtotime($record->strval('start_date'))); }

chus_leon — Fri May 18, 2007 10:16 am

It’s right but if you define one date field that could be null (like any date of end task), it shows 01-01-1970 instead of an empty field.

Is it possible to create a conditional function?

Thanks for the answer and also for the software. It’s nice


shannah — Fri May 18, 2007 10:53 am

Hi,

How about this:
function mydate($format, $time=null){
ÊÊÊÊ if ( $time === 0 ) return ‘‘;Ê // return an empty string if time is 0
ÊÊÊÊ return date($format, $time);
}
Then your delegate class could use this instead of the date function:

function start_date__display(&$record){  
    return mydate('d/m/Y', strtotime($record->strval('start_date')));  
}

I haven’t tested it, but this should work.
Best regards
Steve


chus_leon — Mon May 21, 2007 1:31 am

Sorry, it returns this error

Fatal error: Call to undefined function mydate() in K:\PortableApps\xampp\htdocs\soporte\tables\incidencia\incidencia.php on line 10

on line 10 I have

function fechasoluc__display(&$record){
return mydate(‘d-m-Y’, strtotime($record->strval(‘fechasoluc’)));
}

the function mydate is now defined on ApplicationDelegate.php. I tried also on my incidencias.php and returns the same error

Regards

Jesus


shannah — Mon May 21, 2007 6:17 am

If you define the function mydate(), make sure that it is outside all of your class definitions.

e.g.
class conf_ApplicationDelegate {

ÊÊÊ function mydate(){
ÊÊÊÊÊÊÊ …
ÊÊÊ }
}

IS WRONG!
class conf_ApplicationDelegate {

}
function mydate(){

}
is CORRECT
=Steve


chus_leon — Mon May 21, 2007 7:38 am

That’s right. thanks again

Jesus


chus_leon — Sat Jun 09, 2007 1:08 am

Hi, another solution for the null dates is:

function datefield__display(&$record){
if ($record->val(‘datefield’) == NULL) {
return ‘’;
}else{
return date(‘d-m-Y’, strtotime($record->strval(‘datefield’)));
}
}

Regards