问题描述:

Hey can anyone tell me how I add 0.25 hours to a date.

for example.

$time = 0.25;

$mid = date_create("00:00") ;

and now I want to add $time as hours to $mid

EDIT:

with $time = 0.25 i mean 1/4 of a hour. But i only get variables from 0.01- 0.99;

网友答案:

Use date_add to add $time * 3600 seconds to your $mid date.

$time = 0.25;
$mid = date_create("00:00") ;
date_add($mid, date_interval_create_from_date_string(($time*3600).' seconds'));
echo date_format($mid, 'H:i:s');
相关阅读:
Top