Wouldn't round() work???
<?
$year1 = 2002.75;
$year1 = round($year1);
echo $year1;
// would round UP to 2003

$year2 = 2002.244415755;
$year2 = round($year2);
echo $year2;
// would round DOWN to 2002
?>


Or, if you always want to round down, why not just split it on the decimal?
<?
$year3 = 2002.244415755;
list($y,$d) = explode(".",$year3);
echo $y;
// would echo 2002 regardless of the decimals
?>


Or as long as you're willing to give up year 10,000 compliance :), the year
will "always" be the first four digits.
<?
$year4 = 2002.244415755;
$year4 = substr($year4, 0, 4);
echo $year4;
// should echo the first 4 characters (2002)
?>


Plenty of options :)   I think I'd just use substr()


Justin



on 24/09/02 12:46 AM, Tom ([EMAIL PROTECTED]) wrote:

> Hi all,
> 
> I have a line of code that assigns a new year number: -
> 
> $years = $years + ( $themonth / 12 );
> 
> but sometimes $years == 1998.0833333333
> 
> or
> 
> $year == 2002.75
> 
> etc...
> 
> I cant find anything like a round() or floor() function in PHP so that year
> would be 1998 or 2002 only.
> 
> Does anyone know what function would do this?  Sorry if I`m wasting your
> time if its a really obvious one!
> 
> thanks in advance,
> Tom
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to