Hi monks,

I used the below code using Date::Calc. It's working good. But, my requirement is something exactly with date and minute correct also.

use Date::Calc qw(Delta_YMDHMS); ($day1,$month1,$year1,$hour1,$min1,$sec1) = &getMeanTime; ($day2,$month2,$year2,$hour2,$min2,$sec2) = &getMeanTime; ($D_y,$D_m,$D_d, $Dh,$Dm,$Ds) = Delta_YMDHMS($year1,$month1,$day1, $ho +ur1,$min1,$sec1, $year2,$month2,$day2, $hour2,$min2,$sec2); print sprintf("%02d", $D_d).'/'.sprintf("%02d", $D_m).'/'.sprintf("%04 +d", $D_y).' '.sprintf("%02d", $Dh).':'.sprintf("%02d", $Dm).':'.sprin +tf("%02d", $Ds); sub getMeanTime { my $time = time; my ($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $D +ayOfYear, $IsDST) = gmtime($time); $Year+=1900; $Month+=1; return $Day,$Month,$Year,$Hour,$Minute,$Second; }
If the difference between the date and time zero means i want the same date and time with seconds. But, It showing all date time to zero.

Thanks in advance


In reply to How to find Date and Time difference? by gube

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.