我需要解析一些格式为 ddmmyyyyhhmmssXXX 的时间字符串。 XXX 部分是毫秒。在下面的代码中,我忽略了毫秒部分。它有效,但我收到错误:
garbage at end of string in strptime: 293 at /usr/local/lib64/perl5/Time/Piece.pm line 482.
我应该使用什么样的正确格式。
$time = '11032014182819802';
$format = '%d%m%Y%H%M%S';
$t = Time::Piece->strptime($time, $format);
最佳答案
Time::Piece->strptime(substr($time, 0, -3), $format);
自 Time::Piece
不支持毫秒。
关于Perl strptime 解析毫秒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32240362/