[LA.pm] time conversion question

William Yardley lapm at veggiechinese.net
Thu Jul 27 00:51:50 PDT 2006


On Wed, Jul 26, 2006 at 11:26:06PM -0700, Eric Hammond wrote:
> William Yardley wrote:

> > is there an efficient / simple way to normalize this to (my) localtime
> > in a format for a MySQL timestamp (0000-00-00 00:00:00) without
 
> "Efficient" is relative.  Here's simple:
> 
>   #!/usr/bin/perl -w
>   use strict;
>   use Date::Manip;
>   while ( my $sometime = <DATA> ) {
>     my $datetime = UnixDate(ParseDateString($sometime), '%Y-%m-%d %H:%M:%S');
>     print "$datetime <= $sometime";
[...]

Thanks - this is exactly what I was looking for.

> (I don't know anybody who calls Date::Manip efficient except in
> terms of programmer resources, but it sure is convenient.)

Yeah, and the resulting code is a lot easier to understand, and probably
more tolerant of weird date strings.

w



More information about the Losangeles-pm mailing list