Re: How to convert timestamp to epoch?
- From: Paul Lalli <mritty@xxxxxxxxx>
- Date: Tue, 30 Oct 2007 12:47:12 -0700
On Oct 30, 2:45 pm, "void.no.spam....@xxxxxxxxx"
<void.no.spam....@xxxxxxxxx> wrote:
If I get timestamps in the following format:
22-OCT-07 06.16.44.160000 PM
22-OCT-07 08.16.02.686000 AM
What is the easiest way for me to convert it into the number of
seconds since 1970?
If you convert those first two periods to colons, Date::Parse can
handle it just fine:
#!/usr/bin/perl
use strict;
use warnings;
use Date::Parse 'str2time';
my $date = "22-OCT-07 06.16.44.160000 PM";
$date =~ s/\./:/ for 1..2;
my $epoch = str2time($date);
print "Epoch: $epoch\n";
__END__
Paul Lalli
.
- Follow-Ups:
- Re: How to convert timestamp to epoch?
- From: jl_post@xxxxxxxxxxx
- Re: How to convert timestamp to epoch?
- From: usenet
- Re: How to convert timestamp to epoch?
- References:
- How to convert timestamp to epoch?
- From: void.no.spam.com@xxxxxxxxx
- How to convert timestamp to epoch?
- Prev by Date: Re: Regular Expression and Useage
- Next by Date: Re: How to convert timestamp to epoch?
- Previous by thread: Re: How to convert timestamp to epoch?
- Next by thread: Re: How to convert timestamp to epoch?
- Index(es):
Relevant Pages
|