-1

I have a simple form, and a date that tells when user has submitted:

$timestamp = time();
$time = date("d/m/Y", $timestamp);

Date is sent to my database. Now, on my browse page (that contains all posts that were submitted) I'd like to display a div with "new post" for, let's say 2 days since the publish date. After that time, the div dissapears.

How can I set the time for which my element will be visible?

ilikeoreo
  • 1
  • 2
  • you could simply subtract timestamps. Imagine `today's timestamp - db timestamp`. it will give you the amount of seconds passed since the insertion. two days = 172800 seconds. so, if the subtraction result is greater than 172800, it means 2 days have passed. – GrafiCode Jun 01 '22 at 16:43
  • I think this is very similar to your question: https://stackoverflow.com/questions/10469037/subtracting-two-dates-in-php – GrafiCode Jun 01 '22 at 16:47

0 Answers0