in reply to Coverting Date Formats
You might want to take a look at Time::Piece (alt.), which does just this sort of thing ...
use Time::Piece; my %format = ( Apache => "[%d/%b/%Y:%T -0800]", MySQL => "%Y%m%d%H%M%S", Sybase => "%Y-%m-%d %T -0800", ); my @dates = ( [ "[27/Feb/2002:05:05:51 -0800]" => "Apache" ], [ "2002-02-23 01:27:25 -0800" => "Sybase" ], ); foreach my $date ( @dates ) { my($str,$type) = @$date; my $t = Time::Piece->strptime( $str, $format{$type} ); print $t->strftime( $format{"MySQL"} ), $/; }
--k.
|
|---|