Jump to content

Difference Between Dates


surajkandukuri

Recommended Posts

Hi,

 

  I have two dates stored in array and in the format YYYY-MM-DD and I am unable to find the difference between dates. That is number of years and number of days.

 

          $totaldays[$i]=dateDiff("/",$emp_enddates[$i],$emp_startdates[$i]);

                      echo($totaldays[$i]);

                     

         

            function dateDiff($dformat, $endDate, $beginDate)

{

$date_parts1=explode($dformat, $beginDate);

$date_parts2=explode($dformat, $endDate);

echo($date_parts1[0]);

echo("<br>");

$start_date=gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);

$end_date=gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);

return $end_date - $start_date;

}       

 

    Please help me

Link to comment
https://forums.phpfreaks.com/topic/177967-difference-between-dates/
Share on other sites

Hi,

 

    I still didnot get the thing working !! I am getting the following error

 

  Error type 8

Error description Undefined offset: 1

URL localhost/project1/custompages/summarypage.php?

Error file C:\xampp\htdocs\project1\custompages\summarypage.php

Error line 40

SQL query

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.