2014-09-05 48 views

回答

0

我想出了这个解决方案WHI ch适用于我的应用程序

$value = 11.5; 
$unit = 'year'; //day, second, month,... 

$integer = floor($value); 
$decimal = $value-$integer; 

       //get value of full [unit] and at the percentage from the decmail 
$delay = strtotime('+'.$integer.' '.$unit, 0)+strtotime('+1 '.$unit, 0)*$decimal 
2
echo strtotime('+11 years 6 months'); 

Fiddle

+0

你打我吧! +1 – 2014-09-05 09:49:43

+0

我得到的十进制值如此像11.123年 – Xaver 2014-09-05 09:50:44

+1

您可以使用简单的数学将这些小数转换为月和日 – 2014-09-05 09:51:21

1

你可以试试这个:

echo strtotime('+11 years 6 months');