2
I need some help with logic, but I can’t mount it in PHP (because I don’t want to use this process with mysqli). In the following example, it would be the problem I face, basically.
$hoje = date("Y-m-d"); // Retorna data atual (2018-03-15) formato americano
$inicio_evento = $row['inicio']; // Retorna data 2018-03-15
$fim_evento = $row['fim']; // Retorna data 2018-03-20
As I remarked above, what I need to remedy regarding logic is... If today’s date is between the dates $inicio_evento
and $fim_evento
, then the value is true
.
The problem lies in this logic that I cannot assemble (with IF / ELSE ), and I believe maybe it is because I am confusing the Comparison Operators.
if(strtotime($inicio_evento) == strtotime($hoje) OR strtotime($fim_evento) >= strtotime($hoje)) {
// CODE
}
Could someone give me a little help?
You can use the transitivity principle to check if the current date is between the start and end dates.. i.e.. if A > B and C > B, then C > A. for your case you can check.. if ($data_order >= $today && $today >= $data_start) { true }
– Israel Merljak
Boy... I love you! It turned out just like I needed it!
– user93488