Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Not able to ParseDate lines from a file

by Khen1950fx (Canon)
on Feb 03, 2012 at 13:40 UTC ( [id://951661]=note: print w/replies, xml ) Need Help??


in reply to Re: Not able to ParseDate lines from a file
in thread Not able to ParseDate lines from a file

DateTime::Format::Natural can parse the string for you. You don't have to reinvent the wheel. Try this:
#!/usr/bin/perl -l use strict; use warnings; use DateTime; use DateTime::Format::Natural; my $parser = DateTime::Format::Natural->new; my $extract_string = "Date: 02.07.2011 16:14:48"; my $date_string = $parser->extract_datetime($extract_string); my $dt = $parser->parse_datetime($date_string); my $epoch_time = $dt->epoch; print $epoch_time;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://951661]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-24 11:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found