CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Date Rotuines



Aug 15, 2000, 2:12 AM

Post #1 of 5 (1042 views)
Date Rotuines Can't Post


I need to compare two dates. At the moment my dates are sorted as:


I need to subtract one from the other to be able to compare the difference. However, obviously this can't be done because the 1st of the 9th will have less of a difference than the 14th of the 1st.

Anyway, what I want to do is to convert my date into seconds or minutes of whatever. I need to know what I need to do to have both my dates in a format where I can easily compare them.

Any ideaS?



Aug 18, 2000, 4:07 AM

Post #2 of 5 (1042 views)
Re: Date Rotuines [In reply to] Can't Post

yes, you are correct, you cannot subtract from a formatted date like that, it will not turn out correct.
well, it is kinda hard to give suggestions without a bit more info, Did you convert it to the ddmmyyyy format? if you did, then i would suggest possibly using a 2 fold date, ie: when your script formats a date to ddmmyyyy, have it also send a unformated (in seconds that is) copy to a file, and use that when it is needed. This is with the assumptuion that you formatted the date for a reason other than strictly for kicks and giggles on your part, if not then just dont format it Smile

hope this helps


Aug 18, 2000, 6:42 AM

Post #3 of 5 (1042 views)
Re: Date Rotuines [In reply to] Can't Post

Hi Randor,

Thankyou for our help. I have converted my dates into ddmmyyyy format. What I really need to do now I guess is to convert that string into seconds or minutes? Or I could even convert that into days from 1900 or something. Anyway, the point is how do I go about doing this?


Wiliam Stephens

User / Moderator

Aug 18, 2000, 12:43 PM

Post #4 of 5 (1042 views)
Re: Date Rotuines [In reply to] Can't Post

This is found in the Perl Cookbook (recipe 3.5) to calculate the number of days between two dates.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

use Date::Calc qw(Delta_Days);
$days = Delta_Days( $year1, $month1, $day1, $year2, $month2, $day2);

Date::Calc is available from CPAN at...

I have not used it, but I have heard good things about it.


Aug 19, 2000, 9:04 AM

Post #5 of 5 (1042 views)
Re: Date Rotuines [In reply to] Can't Post

Thankyou, I'll look into this module!




Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives