Rishabh Sharma Rishabh Sharma - 5 months ago 14
PHP Question

PHP date difference calculate onlys for days

My date is in format

day::month::year-h-m-s
now I want to take difference between these 2 dates only in days?

Answer

PHP:

<?php

$otherday = date_create("01-05-2015");
$today= date_create(date("d-m-Y"));

$days = $today->diff($otherday);

echo $days->format("%R%a");

?>

%R means (+) or (-) you can use only %a.