Database date format

I’m looking for a clean way to convert from the database date format (in my case Oracle) to a timestamp that I can then use to display in the locale format (e.g. “01-01-2010”), edit that and then send it back to database format on save.

In CodeCharge (a RAD system) I can define a single "database date format" parameter and it automatically handles this, it would be great if a parameter be defined like:





    'dateFormat'=>'d-M-y', //using PHP date() formatting


Or maybe allow SQL to be defined for DATE types so it either converts to unix timestamp or uses the app’s format directly, e.g.

write: colname = (TO_DATE(‘19700101000000’,‘YYYYMMDDHH24MISS’)+NUMTODSINTERVAL(timestamp,‘SECOND’))

read: timestamp = (colname - TO_DATE(‘19700101000000’,‘YYYYMMDDHH24MISS’)*86400)

or (less usefully)

write: colname = TO_DATE($date, $displayToDbDateFormat)

read: $date = TO_CHAR(colname, $dbToDisplaydateFormat)

What do you think?

I found that this is best handled with a behavior.

I have written one as part of the next release of my extension library, however you can pull it from svn as it is public:



Wrong link, sorry: