bespokeappstt
Hubstaff freelancer
I am using the calc element to calculate the number of days a resource is out and if it's returned late calculate the number of days it late. If it isn't returned, then calculate the number of days it overdue to be in. The following calculations work just fine:
This is what the output looks like
For the first row of data. If today is August 17 2021 then days overdue should be 2 not -738415, because the due date in is August 16 2021. I am troubleshooting a 'php form plugin' code block on serial right now but that shouldn't affect this. It should say 2 for the first row of data. It's possible I have a timezone issue to get around when performing arithmetic between time() and strtotiime() but I'm not sure how to do that.
- days overdue if it was returned late
- do nothing if the schedule has it out
- days overdue if it's late and hasn't been returned.
Code:
$date1 = time();
$date2 = strtotime('{rad_rentals___due_date_out_raw}');
$date3 = strtotime('{rad_rentals___due_date_in_raw}');
$date4 = strtotime('{rad_rentals___actual_date_in_raw}');
if(($date1 > $date3) && ($date4==0)){
return ceil(($date1 - $date3) / 86400); //gives a huge minus figure
}elseif(($date1 > $date3) && ($date4!=0)){
return ceil(($date4 - $date3) / 86400); //this is fine
} else {
return 0 ; //this is fine
}
This is what the output looks like
For the first row of data. If today is August 17 2021 then days overdue should be 2 not -738415, because the due date in is August 16 2021. I am troubleshooting a 'php form plugin' code block on serial right now but that shouldn't affect this. It should say 2 for the first row of data. It's possible I have a timezone issue to get around when performing arithmetic between time() and strtotiime() but I'm not sure how to do that.
Last edited: