1
how can I use the date interval
to count when registering a product, for example I register the product on the 8th I want that in 15 days this product will no longer be a new product or when it is the 23rd this product is no longer new how can I do it using the date interval
?
code :
$criacao_produto = new DateTime($data);
$dias = $criacao_produto->diff(new DateTime())->d;
if($dias < 2)
echo "Produto e novo";
else
echo "produto velho"
Needs to be with date interval cannot be via PHP?
– Ivan Ferrer
Or you just want a Countdown?
– Ivan Ferrer
It is not simple to calculate the difference of the date of creation and today’s date?
– rray
can also be via php and I don’t know which one would be the easiest to do. and type and only one Countdown also because I want it to take today’s date and count 15 days
– Leonardo Costa
how can I calculate the difference of dates I’m seeing tutorials on the internet and type only think of this model: $data_initial = '2013-08-01'; $data_final = '2013-08-16'; // Calculates the difference in seconds between dates $difca = strtotime($data_final) - strtotime($start_date); //Calculates difference in days $days = floor($difference / (60 * 60 * 24)); echo "The difference is $days between";
– Leonardo Costa