Getting the difference

Hi, Can i ask some help how can i get the difference

if the value of my post will be like this.


  $mytimein = $_POST['tmestart'];
  $mytimeout = $_POST['tmeend'];

  echo $mytimein;
  echo $mytimeout;


 output
  start 7:00am
  end  11:00am


Thank you in advance.

The difference? Assuming that you have two date time strings(or objects, but objects cannot come directly from post vars so I assume its formatted string like xx:yy am|pm), you can do the following:


$mytimein = new DateTime($_POST['tmestart']);
$mytimeout = new DateTime($_POST['tmeend']; );
$mytimediff = $mytimeout->diff($mytimein);
echo $mytimediff->format("h:i");

Hi,

There will be no output


     $mytimein = new DateTime('7:00am');
   $mytimeout = new DateTime('11:00am');
   $mytimediff = $mytimeout->diff($mytimein);
   echo $mytimediff->format("h:i"); 


Do you receive an error message? If its a blank page, check your error log to see where the error may be.

Nope

Okay i forgot this

%

Literal %