This question already has an answer here:
Basically what I'm trying to do is do an if command to check a date returned from database vs the current date (todays date or tomorrows date if i go on the page tomorrow)
I was thinking of something along the lines of
$date = "2013-11-10 20:28:41";
if ($date < Curdate)
{
echo "expired";
}
if anyone can give me any insight on the correct commands for this, I would really appreciate it.
</div>
$now = new DateTime(); // Now
$date = new DateTime('2013-11-10 20:28:41'); // From the DB
if ($date < $now)
{
echo "expired";
}
Reference: DateTime()
$dt = new DateTime($date);
$now = new DateTime();
if ($dt < $now) {
echo "before";
}
else {
echo "after";
}