Jeff Pang wrote:
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.


Try to use DateTime module.

my $ystd = DateTime->today->subtract(days => 1);
my $mdy = $ystd->ymd('-');  #date format in 09-25-2007
my $dty = $ystd->mdy('');  #date in format 09252007

u can read more on that module.

Goksie




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


Reply via email to