I need to find the date is expired or not.
Here is my Date. But it was not working for me,
$ActualDate = "2013-03-19 05:05:23";
$ExpiryDate = "2013-04-18 05:05:23";
$elapsedTime = new DateTime($ActualDate);
$now = new DateTime($ExpiryDate);
echo ($now < $elapsedTime ? 'Future' : 'Past');
I cant get the accurate result... if any one knows this, please post a answer it will helpful for me.
The problem is that $elapsedTime
is set to $ActualDate
and $now
to $ExpiryDate
. You probably want to swap them.
<?php
$expires_at = new DateTime('2013-04-19 05:05:23');
$now = new DateTime();
echo $now < $expires_at ? 'Future' : 'Past';