Re: [PHP] Simple Math Calculation Problem....
* Thus wrote Scott Fletcher ([EMAIL PROTECTED]): > 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." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple Math Calculation Problem....
* Thus wrote Scott Fletcher ([EMAIL PROTECTED]): > The int() function is for C/C++ programming only. This Int() function is > not supported in PHP. In PHP it would be Intval(). For float, Floatval(). > For double, DoubleVal(). Etc. But beware of the Octual numbers. You can cast like you can in C/C++ $Days = (int) $value; // C compatible $Days = (integer) $value; // php method Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple Math Calculation Problem....
> The int() function is for C/C++ programming only. This Int() function is > not supported in PHP. In PHP it would be Intval(). For float, Floatval(). > For double, DoubleVal(). Etc. But beware of the Octual numbers. > sorry, confusing my flash action script again :( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple Math Calculation Problem....
Gee! I forgot the '$'. It's been right there in my face. Thanks! I hope the round() function work without a problem because I saw in some posting that some people have this problem where if 3.51 is rounded, it return a 3. "Seth - Kate Buntin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I used your snip you just posted and changed the $Days = round(Days) to $Days = round($Days) and got 228. -Original Message- From: Scott Fletcher [mailto:[EMAIL PROTECTED] Sent: Friday, August 01, 2003 9:18 AM To: [EMAIL PROTECTED] Subject: [PHP] Simple Math Calculation Problem 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); $Days = (($clockDate - $inputDate) / (24 * 3600)); //$Days = round(Days); --snip-- But then I get the idea of doing the round function but it only return a '0' value. Anyone know? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple Math Calculation Problem....
The int() function is for C/C++ programming only. This Int() function is not supported in PHP. In PHP it would be Intval(). For float, Floatval(). For double, DoubleVal(). Etc. But beware of the Octual numbers. "Skate" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > >$Days = (($clockDate - $inputDate) / (24 * 3600)); > > $Days = int(($clockDate - $inputDate) / (24 * 3600)); > > you tried that? > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Simple Math Calculation Problem....
I used your snip you just posted and changed the $Days = round(Days) to $Days = round($Days) and got 228. -Original Message- From: Scott Fletcher [mailto:[EMAIL PROTECTED] Sent: Friday, August 01, 2003 9:18 AM To: [EMAIL PROTECTED] Subject: [PHP] Simple Math Calculation Problem 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); $Days = (($clockDate - $inputDate) / (24 * 3600)); //$Days = round(Days); --snip-- But then I get the idea of doing the round function but it only return a '0' value. Anyone know? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple Math Calculation Problem....
>$Days = (($clockDate - $inputDate) / (24 * 3600)); $Days = int(($clockDate - $inputDate) / (24 * 3600)); you tried that? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Simple Math Calculation Problem....
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); $Days = (($clockDate - $inputDate) / (24 * 3600)); //$Days = round(Days); --snip-- But then I get the idea of doing the round function but it only return a '0' value. Anyone know? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php