[Catalyst] Dealing with timestamps from Postgres

Rippl, Steve rippls at woodlandschools.org
Thu Nov 3 02:46:18 GMT 2011


One way (if using DBIx::Class)

$dt_object =3D $c->model('DB::TableName')->find($row_index)->date_field

(or however your get your resultset)

$formatted_date_string =3D $dt_object->mdy('/');

where the mdy('/') can be whatever the DateTime object you're retrieving
supports (see CPAN docs).

Can obviously be combined into

$formatted_date_string =3D
 $c->model('DB::TableName')->find($row_index)->date_field->mdy('/');

I just split it up to illustrate where the DateTime object is coming from.




On Wed, Nov 2, 2011 at 7:05 PM, Adam Jimerson <vendion at gmail.com> wrote:

> I'm hoping someone can help me with an issue that I am having with dates
> and timestamps that I am pulling out of my Postgres server.
> In my database my time stamps are stored like this 2011-05-07 13:53:41-04
> (timestamp with time zone), 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
> which Catalyst had me install when I first set up my application to use
> the database.  Other than doing a find and replace then stash the
> results every time I want to pull back a date or timestamp is
> there something else that I can do?
>
> _______________________________________________
> List: Catalyst at 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/
>
>


-- =

Steve Rippl
Technology Director
Woodland Public Schools
360 841 2730
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20111102/9a1eb=
0cc/attachment.htm


More information about the Catalyst mailing list