On Dec 12, Paul Kraus said:

>How can I convert a date that is a string such as "12/12/03" to apoch so
>that I can then compare it to time and if its <= time do something.

I suggest using the STANDARD module, Time::Local.  It gives you a function
called timelocal(), which takes six arguments: sec, min, hour, day, mon,
year, in the same way you get them back from localtime().  In your case,
you'd want to do:

  use Time::Local;
  my $date = "12/12/03";
  my ($d, $m, $y) = split '/', $date;
  my $now = timelocal(0,0,12, $d, $m-1, $y+1900);  # (0,0,12) = noon

Ta da.  No big clunky modules, nothing to download from CPAN.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to