Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: MySQL Timestamp from CDBI to TT Date Plugin

by cees (Curate)
on Jun 16, 2005 at 14:56 UTC ( [id://467300]=note: print w/replies, xml ) Need Help??


in reply to MySQL Timestamp from CDBI to TT Date Plugin

You should look at inflating your timestamp values into objects using Class::DBI. You can use Time::Piece::mysql for this, or DateTime::Format::MySQL (there are others as well that will work like Class::Date which is described on the cdbi wiki).

use Time::Piece::mysql; __PACKAGE__->has_a(date_col => 'Time::Piece'); # or use DateTime::Format::MySQL; __PACKAGE__->has_a(date_col => 'DateTime', inflate => sub { DateTime::Format::MySQL->parse_datetime(shift) }, deflate => sub { DateTime::Format::MySQL->format_datetime(shift) });

Then when you have your Class::DBI object, and you retrieve the date column, you will get a Time::Piece or DateTime object that you can pass to the TT Date Plugin in whatever format it accepts.

Or, since your dates are now objects already, just use them directly in TT to format your dates. This removes the need for the Date plugin.

[% date_col.ymd('-') %]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://467300]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-20 09:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found