Re: Simple Math Calculation Problem....
| From: | Curt Zirzow | Date: | Fri, 01 Aug 2003 15:21:53 +0000 |
| Subject: | Re: Simple Math Calculation Problem.... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-157956@lists.php.net to get a copy of this message | ||
* Thus wrote Scott Fletcher (scott@abcoa.com):
> Hi!
>
> I'm a little stuck with this simple math problem. I'm trying to get a
> number of days in integer, not float.
>
> --snip--
> $input_date = "12/16/2002";
> $UserInput = explode("/", $input_date);
>
> $UserInputMonth = $UserInput[0];
> $UserInputDay = $UserInput[1];
> $UserInputYear = $UserInput[2];
>
> $clockDate = mktime(0,0,0,date("m"),date("d"),date("Y"));
> $inputDate = mktime(0,0,0,$UserInputMonth,$UserInputDay,$UserInputYear);
I think strtotime might be more efficient..
$clockDate = strtotime(date("m/d/Y"));
$inputDate = strtotime("12/16/2002");
>
> $Days = (($clockDate - $inputDate) / (24 * 3600));
You can cast it:
$Days = (integer)(($clockDate - $inputDate) / (24 * 3600));
> //$Days = round(Days);
> --snip--
HTH,
Curt
--
"I used to think I was indecisive, but now I'm not so sure."