[Catalyst] now() in insert

J. Shirley jshirley at gmail.com
Fri Feb 6 17:08:10 GMT 2009


On Fri, Feb 6, 2009 at 8:49 AM, Lars Balker Rasmussen <lars at balker.dk> wrote:
> On Fri, Feb 6, 2009 at 5:40 PM, Devin Austin <devin.austin at gmail.com> wrote:
>> On Fri, Feb 6, 2009 at 4:45 AM, Christian Lackas <christian at lackas.net> wrote:
>>>                        dt => \'now()'
>>
>> DateTime also has a ->now method.
>
> Careful now, they may not be identical:
>
> % perl -MDateTime -E 'say DateTime->now'
> 2009-02-06T16:47:48
>
> postgresql=> select now();
>              now
> -------------------------------
>  2009-02-06 17:48:00.240287+01
>
> No timezone in DateTime unless you explicitly ask for it.
>

That's not entirely true, or rather it is an over simplification of it.

http://search.cpan.org/~drolsky/DateTime-0.4501/lib/DateTime.pm#Floating_DateTimes

It has a floating timezone, which is different than "no" timezone.
Storing data in UTC or in floating makes much more sense, since you're
not going to succumb to date math, as illustrated here:
http://search.cpan.org/~drolsky/DateTime-0.4501/lib/DateTime.pm#Local_vs._UTC_and_24_hours_vs._1_day

-J



More information about the Catalyst mailing list