$now = date("H:i:s", time());
$newTime = strtotime("$now +4 hours -7 minutes");
or
$newTime = strtotime("$now +3 hours +53 minutes");
echo "New time is: " . date("H:i:s", $newTime);
something like this?
Вопрос
How can I add hours as well as subtract minutes to get one result?
I can add 4 hours using the following code:
//Current Time
$hourMin = date('H:i:s');
echo "Current time is: ". $hourMin."<br>";
$hourDiff = date('H:i:s', time()+14400000);
echo "New time is: " . $hourDiff;
I can subtract 7 minutes using the following code:
//Current Time
$hourMin = date('H:i:s');
echo "Current time is: ". $hourMin."<br>";
$hourDiff = date('H:i:s', time()-420000);
echo "New time is: " . $hourDiff;
How do I do this so that my time in variable $hourDiff is 4 hours ahead but 7 minutes behind?
Решение
$now = date("H:i:s", time());
$newTime = strtotime("$now +4 hours -7 minutes");
or
$newTime = strtotime("$now +3 hours +53 minutes");
echo "New time is: " . date("H:i:s", $newTime);
something like this?