in reply to Converting string to date

In the end you'll notice it just takes a couple of lines of code to do it - whatever you may write yourself will be longer and more error prone. See this example:
use Date::Manip; $main::TZ = "CET"; my $ds = '2003/10/19'; # it's a sunday my $d = &ParseDate( $ds ); print "$ds = $d \n"; my $d2 = &DateCalc( $d,"+ 3hours 12minutes 6 seconds", \$err); print "$d2\n"; my $d3 = &DateCalc( $d,"+ 5 business days", \$err); print "$d3\n";
Note how you can even use business days when doing date operations (that's why $d3 looks weird at first...). I think it's no point reinventing the wheel. :-)

On the other side, Date::Manip is big and slow, so if you have to compute thousands or millions of operations with it in a few seconds, it's not likely the way to go....

Replies are listed 'Best First'.
Re: Re: Converting string to date
by marctwo (Acolyte) on Nov 26, 2003 at 15:58 UTC
    Thank you all for your suggestions. I finally got Date::Manip to work and am happily using that. I honestly don't know what I would do without Perl Monks!

    Marc