Page 1 sur 1

Date diff

Posté : 29 mars 2013, 11:54
par Medesko
please can u help me Fatal error: Cannot redeclare date_diff()
<?php
$date1 = date("29/03/2013");
$date2 = "01/04/2013";
function date_diff($date1, $date2)
{
$s = strtotime($date2)-strtotime($date1);
$d = intval($s/86400)+1;
return "$d";
}
echo date_diff($date1, $date2);

?>

Re: Date diff

Posté : 29 mars 2013, 13:35
par benv8nam
La fonction date_diff prend en paramètre des type DateTime et non date.

Re: Date diff

Posté : 29 mars 2013, 14:11
par moogli
Hi,

The function 'date_diff()' is a php function http://php.net/date_diff.

Change function name or, better, use php date_diff function (or directly a datetime object )


thank you for writing in French on the forum as much as possible :)


@+