This question already has an answer here:
how can I subtract some hour and minute form the current datetime in php?
example: current date: 2016-11-22 14:15:50 I need to deduce 1 hr & 25 minute from this ..
how can I do this?
</div>
$time = time()-1*60*60-25*60;
echo date('Y-m-d H:i:s', strtotime($time));
This code might help you :
$newTime = strtotime('-15 minutes'); // as per your question it should be 85
echo 'Time: '.date('Y-m-d H:i:s', $newTime);
Easy solution: with PHP DateTime
$date = new DateTime('2016-11-22 14:15:50');
$date->sub(new DateInterval('P0Y0M0DT1H25M0S'));
echo $date->format('Y-m-d H:i:s') . "
";
P is period & T is Time.And you know: Y= Year, M= Month, H= Hour, M= Minutes, and S= Second
.Just put your required time before these.You can blank DateTime()
to get current time.
Using simply strtotime
echo date("Y-m-d H:i:s",strtotime("-1 hour -25 minutes"));
Using DateTime
class
$date = new DateTime("-1 hour -25 minutes");
echo $date->format("Y-m-d H:i:s");