On May 10, 2007, at 9:05 AM, RA Jones wrote:
Adam Herzog wrote:
I generally prefer receiving the DateTime object, though, since my formatting is usually dependent on what I'm doing with the data. If you're using something like Catalyst, I'd pass the DateTime object down to the view, and let it decide how to format it.
Sounds like something for a TT snippet - but how do I call the DateTime object in the template (yes I'm using Cat)?

The DateTime object has a dmy() method which should format the date how you want it (dd-mm-yyyy), so displaying it should be pretty straightforward.

In your previous code you were doing something similar to this in your controller:
while ( my $hits = $rs->next ) {
    push @hits, $hits->date;
}

That should fill @hits with DateTime objects. Assuming you stick @hits into your stash, then in your template you can do:

[% FOR hit IN hits; %]
        Date: [% hit.dmy(); %]<br />
[% END; %]

That should display a list of all of the dates, formatted how you wanted.

-A

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to