I have two dates and times I have to compare. I have current_date and requested_date(in the format of mm/dd/yr hr:min:sec). I have to check the difference between the two and do some processing if the time difference is >= 1hr. I was doing it initially with compaing the times but later realized that if requested date is between 23:00 and 24:00 of a day then this condition will nevere be reached. Any other ideas on how can I get the diffrence?
$cur_time = GetCurrentTime(); ($cdate, $ctime) = split(/ /, $cur_time); ($chour,$cmin,$csec) = split(/:/, $ctime); $current_time = ($chour*3600) + ($cmin*60) + $csec; same way for the req time: $requested_time = ($hour*3600) + ($min*60) + $sec; if (($current_time - $requested_time) >= 3600 Do processing.....
I tried the above code....

In reply to Compare Date and Time by anne

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.