I have taken a look at the DateTime-Format-MySQL and it can produce the formats required however with out being able to get the format through a call as described above it will never work with Class::DBI.
Here's what I use in a similar situation...in the base class for my DB, the one that inherits directly from Class::DBI, I have the following:
-------
sub _register_dates { my $class = shift; $class = ref $class if ref $class; foreach my $column (@_) { $class->has_a( $column => 'DateTime', inflate => \&_date_inflate, deflate => \&_date_deflate, ) } $class; }
sub _date_inflate { DateTime::Format::MySQL->parse_datetime (shift) } sub _date_deflate { DateTime::Format::MySQL->format_datetime(shift) }
--------
Then, in any table-specific classes involving MySQL datetime fields, I register the datetime columns thusly:
__PACKAGE__->_register_dates(qw(date_col1 date_col2 date_col3));
Seems to work well so far.
Cheers, Matt