On 10/22/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> HI
> I need to get the $to as 18-10-2007
> But it throws as 18.can u give the suggestion to get the
> same format?
> Thanks........
>
> #!/usr/perl/bin
> $from="15-10-2007";
> $to=$from+"3";
> print "$from,\n";
> print "$to";
>
It looks like you want to do date translation.For this purpose you
can't use this $date + N way.Consider your current day is
'2007-9-30',what would get by $date+3?
Instead you can use the way below to get the date after 3 days:
use strict;
use Time::Local;
use POSIX 'strftime';
my $from="15-10-2007";
my ($day,$mon,$year) = split/-/,$from;
my $time = timelocal(0,0,0,$day,$mon-1,$year);
print strftime("%d-%m-%Y",localtime($time + 86400*3));
Hope this helps.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/