Thanks, I created subroutine to do this that will return -1 if lesser, 0 for equal and 1 for greater.

sub Date_Comp { my %months= {Jan => 1,Feb => 2,Mar => 3,Apr => 4,May => 5,Jun => +6,Jul => 7,Aug => 8,Sep => 9,Oct => 10,Nov => 11,Dec => 12}; my($date1, $date2)= @_; my @dates1= split (" ",$date1); my @dates2= split (" ",$date2); my @times1= split (":",$dates1[3]); my @times2= split (":",$dates2[3]); my $days1= $dates1[4]*365 + $months{$dates1[1]}*30 + $dates1[2];p +rint "\ndays1= $days1"; my $days2= $dates2[4]*365 + $months{$dates2[1]}*30 + $dates2[2];p +rint "\ndays2= $days2"; my $time1= $times1[0]*60*60 + $times1[1]*60 + $times1[2]; print " +\ntimes1= $time1"; my $time2= $times2[0]*60*60 + $times2[1]*60 + $times2[2]; print " +\ntimes2= $time2"; if ($days1 > $days2) { print "\n $date1 is latest \n"; return 1 } elsif ($days1 < $days2) { print "\n $date2 is latest \n"; return -1 } elsif ($days1 == $days2) { if ($time1>$time2) {print "\n $date1 is latest \n"; return 1 } elsif($time1<$time2) {print "\n $date2 is older \n"; return -1} elsif($time1 == $time2) {print "\n Both are same \n"; return 0 } } }

In reply to Re^2: Ctime/Mtime compare with string date by bimleshsharma
in thread Ctime/Mtime compare with string date by bimleshsharma

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.