[Catalyst] Dealing with timestamps from Postgres
Adam Jimerson
vendion at gmail.com
Thu Nov 3 10:40:41 GMT 2011
The problem I see with doing it this way: $formatted_date_string =3D
$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 =3D $c->stash->{mydata_rs}->search(
undef,
{
order_by =3D> { -asc =3D> 'uniq' },
},
);
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 <bobtfish at bobtfish.net> 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 :)
>
> Cheers
> t0m
>
>
>
>
> ______________________________**_________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-**bin/mailman/listinfo/catalyst<ht=
tp://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst>
> Searchable archive: http://www.mail-archive.com/**
> catalyst at lists.scsys.co.uk/<http://www.mail-archive.com/catalyst@lists.sc=
sys.co.uk/>
> Dev site: http://dev.catalyst.perl.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20111103/a90d0=
e54/attachment.htm
More information about the Catalyst
mailing list