In PHP, how could I create a variable called $livetime
that equals the current time minus 1 hour?
$livetime = time() - 3600; // 3600 seconds in 1 hour : 60 seconds (1 min) * 60 (minutes in hour)
See time PHP function for more information.
Another way - without all the math and, in my opinion, reads better.
$hour_ago = strtotime('-1 hour');
Here you go:
<?php
$now = time();
echo strftime("%c",$now) . "\n";
$livetime = $now-3600;
echo strftime("%c",$livetime) . "\n";
?>