![]() |
lefty 2/8/2020 |
I have Two Feilds, DateDue DateArrived I want to see if the difference is more than two days and the if it is colour the row, I am doin gthis on the list page After REcord is processed. datediff($data['DateDue'],$data['Datearrived']) as days_diff; If days_diff > 2 $record["css"]="background:yellow;"; However I get error on the first line : syntax error, unexpected 'as' (T_AS) in line 37
|
W
|
whiz_kid_uk author 2/9/2020 |
Thanks John, Although still does not work.. $date1=$data["DateDue"];
Try This: $date1=$data["DateDue"]; $date2=$data["Datearrived"]; $diff=date_diff($date1,$date2); If ($diff > 2) { $record["css"]='background:yellow;'; } else { } |
![]() |
Admin 2/9/2020 |
date_diff and similar functions work with DateTime values while what you have in the $data array are strings. Before performing your calculations you need to convert string values either to DateTime objects or to number of seconds. I recommend using the second approach explained in this article: https://www.geeksforgeeks.org/how-to-calculate-the-difference-between-two-dates-in-php/ |
W
|
whiz_kid_uk author 2/10/2020 |
Sergey ! Thank you worked Perfectly !! |
![]() |
lefty 2/10/2020 |
Sergey ! Thank you worked Perfectly !!
|