Dates in PHP (Tomorrow, Yesterday, Today of a Given Date)

Dates in PHP (Tomorrow, Yesterday, Today of a Given Date)


echo “Date Yesterday”;

$yesterday = date(“Y-m-d”, time()-86400);
echo $yesterday;

echo “Date Today”;

echo date(“Y-m-d”);

echo “Date Tomorrow”;

$tomorrow = date(“Y-m-d”, time()+86400);
echo $tomorrow;

echo “Previous Date from User-defined Date”;


$gdate = “2008-07-11″;
echo “(” . $gdate . ” supplied.) ”;
$dt = strtotime($gdate);
echo date(“Y-m-d”, $dt-86400);

echo “Next Date from User-defined Date”;

echo “(” . $gdate . ” supplied.) ”;
$dt = strtotime($gdate);
echo date(“Y-m-d”, $dt+86400);

// DAYS IN BETWEEN TWO DATES

function days_in_between($s, $e){
$d = array();
$s = strtotime($s);
$e = strtotime($e);
for($n=$s; $n<=$e; $n=$n+86400){
array_push($d, strftime(“%Y-%m-%d”, $n));
}
return $d;

}

?>

Comments

Popular posts from this blog

Xampp MySQL not starting

Multiple Login in Google Talk!