Gez
05-18-2008, 06:53 PM
I have two user imputted dates in the format (YYYY-MM-DD) and i need to work out the number of days between the two dates. I found this code but i cant seem to get it to work! Does anone have any alternaivs or suggestions?
function dateDiff($dformat, $endDate, $beginDate)
{
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $endDate);
$start_date=gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]);
$end_date=gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]);
return $end_date - $start_date;
}
This is my version of the code:
Function staylength(){
$checkin=$_REQUEST['checkin'];
$checkout=$_REQUEST['checkout'];
$date_parts1=explode("-", $checkin);
$date_parts2=explode("-", $checkout);
$checkin=gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
$checkout=gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
$staylength = $checkout - $checkin;
echo $staylength;
}
function dateDiff($dformat, $endDate, $beginDate)
{
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $endDate);
$start_date=gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]);
$end_date=gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]);
return $end_date - $start_date;
}
This is my version of the code:
Function staylength(){
$checkin=$_REQUEST['checkin'];
$checkout=$_REQUEST['checkout'];
$date_parts1=explode("-", $checkin);
$date_parts2=explode("-", $checkout);
$checkin=gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
$checkout=gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
$staylength = $checkout - $checkin;
echo $staylength;
}