How do I parse microseconds with Time::Piece strptime?
perl
Solution
Time::Piece doesn't support sub-second times. Try DateTime instead, for example, DateTime::Format::Strptime:
use DateTime::Format::Strptime;
my $parser = DateTime::Format::Strptime->new(
pattern => '%d-%b-%y %I.%M.%S.%6N %p',
);
my $dt = $parser->parse_datetime("25-OCT-10 04.11.00.000000 AM");
Problem
I have a timestamp that looks like `25-OCT-10 04.11.00.000000 AM`. I'm trying to convert this to a time format with ``` Time::Piece->strptime("25-OCT-10 04.11.00.000000 AM","%d-%b-%y %I.%M.%S.%6N %p") ``` but it keeps throwing errors. I've tried `%OS`, `%SZ`. They dont seem to work. Can someone tell me what I'm doing wrong?