[Catalyst] SQLite Dates

Brandon Black blblack at gmail.com
Fri Mar 17 23:46:37 CET 2006


On 3/17/06, Kevin White <kevin at theconfused.co.uk> wrote:
> Hi folks,
>
> I am using SQLite for a quick app and within the app are some dates
> that I am presenting in dd-MMM-YYYY. Trouble is SQLite requires them
> in YYYY-MM-DD HH::MM::SS for it to do anything useful with. How would
> I go about converting the incoming dates to the correct DB format and
> vice versa? Anyone got any examples or could point me to one?
>
> Thanks for any help
>

The DateTime module on CPAN has the ability to accept arbitrary
input/output formats IIRC, you could convert via that.

Another way people sometimes solve this problem that works on all
database vendors pretty well is to not use the database's notion of
time/date-stamps at all, and instead work with unix time numbers
(integer seconds since midnight Jan 1, 1970 UTC) that are returned by
perl's builtin "time" function, and just store them as integers, and
use any method you feel like to convert them into an arbitrary display
format ( localtime, strftime, DateTime, etc).

-- Brandon



More information about the Catalyst mailing list