I’ve got an array that out puts the value like 11100111, is there a way to add all these values together.
The function (i want to work out the total amount of days spent on a task) grabs the date values (day, month and year), they’re seperate, puts them together for the date i started the task and the date i ended the task. I know I’m problaby doing this the wrong way but as always, if you can help please do…
function total_days(){
$hours_spent = query("SELECT * FROM tasks");
confirm($hours_spent);
while($row = fetch_array($hours_spent)) {
$start_year = $row['start_year'];
$start_month = $row['start_month'];
$start_date = $row['start_date'];
$end_year = $row['end_year'];
$end_month = $row['end_month'];
$end_date = $row['end_date'];
$started_on = $start_year."-".$start_month."-".$start_date ;
$ended_on = $end_year."-".$end_month."-".$end_date ;
$date_start= strtotime($started_on );
$date_end = strtotime($ended_on);
// Get the difference and divide into
// total no. seconds 60/60/24 to get
// number of days
//echo "Difference between two dates: ". ($date_end - $date_start)/60/60/24;
$updated_start_end_day = ($date_end - $date_start)/60/60/24;
$updated_no_of_days = $updated_start_end_day + 1;
//echo "<p>The amount of days worked on this project is updated date ".$updated_no_of_days."</p>";
echo $updated_no_of_days;
}
}
Thanks
Darren