Output date() in php with an arbitrary offset
Tell me how to output as short as possible in php
echo (date("d M Y в H:i"));
With a random offset in minutes from the current time, for example, take away 34 minutes?
1
2 answers
Time
$time = time() - 34 * 60; // секунды
echo date('d M Y в H:i', $time);
Strtotime
$time = strtotime('-34 minutes');
echo date('d M Y в H:i', $time);
DateTime
$date = new \DateTime('-34 minutes');
echo $date->format('d M Y в H:i');
2
Author: luchaninov, 2016-05-21 18:57:15
echo (date("d M Y в H:i", time()-34));
0
Author: Viktor, 2016-05-21 14:29:18