Check 2 values after . (point)

Asked

Viewed 42 times

1

I am developing a code where I have to calculate daily parking. In case the user selects for example:

From: 05-11-2015 15:00 Until 06-11-2015 15:00

The value to be returned is 1, that is, 1 night. If the user selects:

From: 05-11-2015 15:00 Until 06-11-2015 16:00

The value to be returned will be 1.xxxxx And so on. What I need to know is if there is a value after . (point) then means that it is one more daily beyond the value of the left (which in the case of example is 1).

The code I currently have is

<?php
$entrada = strtotime('2015-11-05 10:00');
$saida = strtotime('2015-11-10 11:00');

$diaria = ($saida-$entrada) / (60*60*24);

echo $diaria;
?>

It makes the right calculation, I just really need to know if it has any value after . to count as + 1 daily.

1 answer

3


Try to use the function Ceil, I think it helps you in this case.

Hug

  • Yeah, that’s the solution I thought of when I wrote the post. It really worked, thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.