[wd_asp elements=’search’ ratio=’100%’ id=1]

Take off / Add time to PHP variable

5th September 2013

Php - Dates & Time

php codehaven

Simplest script


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.


$date1="04:12";
$newtime = strtotime($date1);
$newtime = strtotime("-1 hour", $newtime);
echo "
";
echo date("H:i",$newtime);