Good morning how can I do a system that registers the current date in the bank and then I want it to show as new type so I want it while the date it was registered is less than 15 days it shows as new and then it quit how to do that?
Good morning how can I do a system that registers the current date in the bank and then I want it to show as new type so I want it while the date it was registered is less than 15 days it shows as new and then it quit how to do that?
In your SQL to select the date:
SELECT * FROM tabela WHERE
data BETWEEN CURRENT_DATE()-15 AND CURRENT_DATE();
If the return is positive (true), the date is less than 15 days, then, it is not new ... if it is negative (false), it is new.
Reference issue: Search the data of the last 7 days from the current date
As I imagine you want to bring the object independent of it being new or not, I suggest the following logic:
// $objeto é o objeto que você trouxe do banco, e possui a data como um atributo
$novo = false;
if ($objeto->getData()->diff(new \DateTime())->days <= 15) {
$novo = true;
}
Just do what you want based on the contents of $novo
: if you will display an image, a button etc.