Simplest script
1 2 3 |
echo $date = date("Y-m-d H:i:s", strtotime('-24 hours', time())); |
This script takes off or adds on any amount of time to an existing time.
1 2 3 4 5 6 7 8 9 |
<?php date_default_timezone_set('Europe/London'); $date1="2013-02-26 00:00:00"; $newtime = strtotime($date1); $newtime = strtotime("-5 months", $newtime); echo date("Y-m-d",$newtime); ?> |
1 2 3 4 5 6 7 |
$date1="04:12"; $newtime = strtotime($date1); $newtime = strtotime("-1 hour", $newtime); echo "<br>"; echo date("H:i",$newtime); |