in reply to Format XML Atom DateTime

my $xmljunk = "2012-02-25T18:48:34.835-05:00 "; my $desired = $xmljunk; $desired =~ s/T/ /; $desired =~ s/\..*$//; print "$xmljunk\n$desired\n\n"; __END__ 2012-02-25T18:48:34.835-05:00 2012-02-25 18:48:34

Replies are listed 'Best First'.
Re^2: Format XML Atom DateTime
by omegaweaponZ (Beadle) on Feb 26, 2012 at 00:21 UTC
    Ha, thanks. Regular expressions are a sneaky way of doing this. Occasionally this will not end in a decimal value, so the -0500 of EST will still show up, but this is a minor annoyance that can be fixed. Just for reference, is the xml date format I mentioned able to be identified and re-formatted using Date::Format or another perl module?

      Just for reference, is the xml date format I mentioned able to be identified and re-formatted using Date::Format or another perl module?

      Never used Date::Format before, but a minute of looking shows its should be able to handle it without any problem

      #!/usr/bin/perl -- use strict; use warnings; use Date::Format(); use Date::Parse(); use feature qw/ say /; my @t = Date::Parse::strptime( q/2012-02-25T18:48:34.835-05:00/); say Date::Format::strftime( q/%Y-%m-%d %H:%M:%S/, @t, ); __END__ 2012-02-25 18:48:34