Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Open Source > Perl
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Perl section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 18th, 2007, 08:34 AM
Friend of Wrox
Join Date: Dec 2003
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts

A function called strftime is what you're after. It's in the POSIX and Date::Format CPAN modules

Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk
Old April 25th, 2007, 06:23 PM
Registered User
Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

I want to compare the date which i get read from the xml file with today's date and if it is greater than 60 days then need to do a action else other action.

Please share ur views with me,

Thanks in advance

Old June 7th, 2007, 04:57 AM
Registered User
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

This below prog is to calculate the diff of days.
I hardcoded most. if you want to use dd-mm-yy format you can use split function for date arrays.

                    # perl binary

@std_date=(1,1,1800); # cal starts from this year

@date_one=(21,06,2006); # first date
@date_two=(20,06,2007); # second date

@days_of_month=(31,28,31,30,31,30,31,31,30,31,30,3 1);

$count1=no_day(@std_date,@date_one); # date_one - std_date
$count2=no_day(@std_date,@date_two); # date_two - std_date
$count=($count1 > $count2) ? $count1 - $count2 : $count2 - $count1;
                    # date1 - date2

print "\n\tNo of days : $count\n\n";

sub no_day

    #adding the days for year
        $count+=365 if(leapyear($i));
        $count+=366 if(!(leapyear($i)));

    #adding the days for month

    #adding the days and return


sub leapyear # is it leap year
            return(0); # if leap year
    return(1); # if it is not leap year

Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between 2 dates comicghozt Access 5 July 14th, 2006 03:45 AM
Urgent! how to calculate difference between dates Subuana Beginning VB 6 2 March 22nd, 2006 05:34 PM
Difference in Dates mcinar Javascript How-To 0 May 8th, 2005 07:08 PM
Difference between two dates in Vb.net bimal VS.NET 2002/2003 5 August 15th, 2004 11:32 PM
how to calculate difference in dates ashu_gupta75 Excel VBA 3 August 9th, 2004 06:11 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.