surajkandukuri Posted October 16, 2009 Share Posted October 16, 2009 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 More sharing options...
teynon Posted October 16, 2009 Share Posted October 16, 2009 I'm being kind of lazy right now, so I haven't throughly inspected this, but try changing $totaldays[$i]=dateDiff("/",$emp_enddates[$i],$emp_startdates[$i]); to $totaldays[$i]=dateDiff("-",$emp_enddates[$i],$emp_startdates[$i]); Link to comment https://forums.phpfreaks.com/topic/177967-difference-between-dates/#findComment-938341 Share on other sites More sharing options...
surajkandukuri Posted October 16, 2009 Author Share Posted October 16, 2009 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 Link to comment https://forums.phpfreaks.com/topic/177967-difference-between-dates/#findComment-938376 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.