I don't have much knowledge in php and I didn't find something to help me, you are my last hope.
I have a variable that receive a datetime and a variable that receive an empty array.
I do a foreach on an object that I call $file. This object has a property ($file[6]) which is the datatime and another with the name ($file[0]). I need to add the object to the array IF the datetime of $file[6] is greater than 10 minutes or less than 10 minutes of createDate and return a array with the results ( [ $file[0], $file[6] ] ). As you can see in the code below:
$createDate = $prop['created_date'];
$result = array();
foreach($obj['files'] as $file) {
if (???) {
// Here I need to compare one date with another and if the date is
// greater than 10 minutes OR less than 10 minutes I take this result
// and add it into the empty array, if not, I do nothing.
array_push($result, $file)
}
}
echo json_encode($result);
Var_dump results in $createDate and $file:
$createDate:
DataType: json Message: object(IP_DateTime)#77 (3) {
["date"]=>
string(26) "2022-04-25 03:38:15.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(17) "America/Sao_Paulo"
}
$file:
array(9) {
[0]=>
string(26) "20220407_10_22_30_L100.SVL"
[1]=>
int(2)
[2]=>
string(8) "20220407"
[3]=>
int(4766)
[4]=>
int(307)
[5]=>
int(101366)
[6]=>
string(19) "2022-04-07 13:34:10"
[7]=>
int(0)
[8]=>
int(1)
}
How can I add these values to the array?