如何在PHP中比较2次

I want to check current times is greater than 12.00 pm or not in PHP I have tried this code

<?php
       date_default_timezone_set('Asia/Kolkata');
       $currentTime = date( 'h:i:s A', time () );
       echo $currentTime;
              //var_dump($currentTime);


       $tm="12:00:00 PM";
      $from= date("h:i:s A", strtotime($tm));
      echo $from;
      //var_dump($from);
      if($currentTime>$from){
      echo "success";
       }
 ?>

but it is comparing times as string. If the current time is 2.00pm it is not printing success.

Use the binary timestamps for calculations and comparing, and convert them only to text for displaying. This is more efficient than managing all as time strings. Add differences can be build by a simple and fast subtraction ($delta = $currentTime - $from).

The modified code may look like this:

<?php
date_default_timezone_set('Asia/Kolkata');

$currentTime = time(); // very fast function
echo date('h:i:s A',$currentTime);

$tm="12:00:00 PM";
$from = strtotime($tm);
echo date('h:i:s A',$from);

if ( $currentTime > $from ){
   $delta = currentTime - $from;
   echo "success, delta $delta seconds";
}
?>