Reputation: 11662
I like to get the seconds from a string like 11.5 years
. Using strtotime()
return a negative value
strtotime('11.5 years', 0)
which is explained here
Upvotes: 0
Views: 47
Reputation: 11662
I came up with this solution which works for my application
$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
Upvotes: 0