S, Rajini (STSD) wrote:
Hi,
I am new to Perl Programming and have a query in perl.
In perl is there any system defined functions to find out the
Differences in dates.
Eg :
Date 1 -> 26-Jan-2009
Date 2 -> 14-Jan-2009
So the difference between two dates is 12 days.
Is there a way to achieve this with any system defined functions
In Perl ????
It depends on what you mean by "system defined functions". As others
have told you, there are many CPAN modules that deal with date and time
related tasks. Your particular problem can be easily solved using only a
module that is included in the standard Perl distribution.
use Date::Parse;
my $time1 = str2time '26-Jan-2009';
my $time2 = str2time '14-Jan-2009';
print 'Difference: ',
sprintf( '%.0f', ($time1-$time2)/86400 ), " days\n";
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/