in reply to Converting localtime to SQL format

In addition to the good answers you already got, I think it is worth reminding that most perl functions return different values according to the context. In this case it wouldn't be too hard to roll your own(TM) solution:
my $time = do { my ($s,$m,$h,$D,$M,$Y)=localtime; $Y+=1900; $M++; "$Y-$M-$D $h:$m:$s" };
UPDATE: I added $M++ which was not not there as per crenz's warnings.

Replies are listed 'Best First'.
Re^2: Converting localtime to SQL format
by crenz (Priest) on Mar 30, 2005 at 08:55 UTC

    You provide a good reason to rather use Posix::strftime(): Your solution is wrong since the month is zero-based and you forgot to increment the month.

      You provide a good reason to rather use Posix::strftime(): Your solution is wrong since the month is zero-based and you forgot to increment the month.
      Indeed. Mine was more of an example especially aimed at reminding of different contexts.