On 03/11/2011, at 9:40 PM, Adam Jimerson wrote:

The problem I see with doing it this way: $formatted_date_string =
$c->model('DB::TableName')->find($row_index)->date_field->mdy('/'); is
that It looks like I would
have to do this every time I grab a date from the database. That is fine
but there are times in my app where I pull everything from the database to
display like so:

my $things = $c->stash->{mydata_rs}->search(
order_by => { -asc => 'uniq' },

One option is to define a method in whatever Result class mydata_rs produces:

sub my_date_format {
my $self = shift;
return $self->date_field->mdy('/');

then in your template:

[% WHILE (row = mydata_rs.next); row.my_date_format ; END %]

or you can just call the datetime methods in the template:

[% WHILE (row = mydata_rs.next); row.my_date_field.ymd('/') ; END %]

where each item has a timestamp of when it was created and when it was last
modified, would I have to do another search to get the datetime formatted
or worse pull them one by one building a hash_ref or array?
On Thu, Nov 3, 2011 at 6:04 AM, Tomas Doran wrote:

On 3 Nov 2011, at 02:05, Adam Jimerson wrote:

but in my Catalyst app the
date looks like this 2011-05-07T13:53:41. The "T" instead of the space
is driving me crazy, I think it is coming from DateTime::Format:Pg
As other people have noted, what's happening is that DateTime::Format:Pg
is parsing the dates you get out of Postgres, and handing you a DateTime
object back.

You're then printing that with no formatting, as you're basically getting
an ISO8601 timestamp out.

Have a look at the docs for DateTime and the associated
DateTime::Format::XX things :)


List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-**bin/mailman/listinfo/catalyst<http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst>
Searchable archive: http://www.mail-archive.com/**
Dev site: http://dev.catalyst.perl.org/
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 7 of 16 | next ›
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedNov 3, '11 at 2:05a
activeNov 3, '11 at 9:21p



site design / logo © 2018 Grokbase