Your code worked great! The only problem with that was you had month.day.year . I tried changing the script to allow the new format but I can't seem to get it to work now. The script below prints these results:
05.05.06 09.03.04 31.02.04 15.01.04 16.01.04 15.01.04 01.01.04 01.01.04 14.09.04 01.01.04 01.01.04 01.01.04 04.05.06 Day: 05 Month: 05 Year: 06 Day: 09 Month: 03 Year: 04 Software error: Day '31' out of range 1..29 at line 43
Can you help me set it up so it works in this new format? it always dies on the third entry because the day is 31 when the error says it can only be 1..29.

Thank you!

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); my $today = time; print "$today<br><br>"; foreach (keys %entries) { my ($date, $course, $location, $job_type, $contact) = split(/::/, $e +ntries{$_}); print "$date<br>"; } foreach (keys %entries) { my ($date, $course, $location, $job_type, $contact) = split(/::/, $e +ntries{$_}); my ($d,$m,$y) = split /\./, $date; my $saved_date = timelocal(0,0,0,$d,$m-1,$y); my $days_diff = int( ($today - $saved_date) / (24*60*60) ); print "Day: $d Month: $m Year: $y<br>"; }

In reply to Re: Re: Calculating between times by Anonymous Monk
in thread Calculating between times by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.