On Tue, 12 Feb 2002 17:03:00 -0600, Shawn <[EMAIL PROTECTED]> wrote:
> How might I convert a date/time string to epoch seconds?
> 
> For example, taking "02/05/2002 02:31:14" and convert to epoch seconds.

One easy way to do it is to use the standard Time::Local module:

#!/usr/bin/perl -w
use strict;
use Time::Local;

my $time_string = "02/05/2002 02:31:14";

my ($mday,$mon,$year,$hours,$min,$sec) = split(m![/ :]!, $time_string);
my $time = timelocal($sec,$min,$hours,$mday,--$mon,$year);

print "Epoch: $time\n";

__END__

-- 
briac
 << dynamic .sig on strike, we apologize for the inconvenience >>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to