i have an Array with this string value.
[VALIDUNTIL] => 28.08.23
Now i need to compare it with the todays date and check if the VALIDUNTIL date is in the same month and year as the today´s date
i looked for a while now but i cant find any solution.
while ($row = oci_fetch_assoc($dbResult))
{
$data[] = $row;
}
foreach($data as $ar) {
if ($ar['VALIDUNTIL'] && $ar['VALIDUNTIL'] != null) {
if(strtotime($ar['VALIDUNTIL']) >= strtotime($date)) {
}
}
When i try to do it with timestamps it cant read the VALIDUNTIL date and gives me the 1970 timestamp
strtotime seems not to work too.
tnx 4 help.
2
Answers
Here are the PHP string conversions for time ref. https://www.w3schools.com/php/php_ref_date.asp
You’d need to have both dates in the same format. The above is from : https://www.w3schools.com/php/func_date_strtotime.asp#:~:text=The%20strtotime()%20function%20parses,are%20mapped%20to%201970%2D2000.
if you echo (strtotime($ar[‘VALIDUNTIL’]) and strtotime($date)) back to the screen then you can visually compare and check to see the format which you are using is the same for both dates and adjust accordingly.