I have been looking through various posts on here to find my solution but i can't find one :(
so what i am after is a way of finding the exact difference between to dates. I currently have the following code
$date = time();
$publishedDate = strtotime($item->published_time);
$datediff = $date - $publishedDate;
$daysListed = floor($datediff/(60*60*24));
if($daysListed >= 2)
{
$days = $daysListed." days ago";
}
elseif ($daysListed == 1)
{
$days = $daysListed." yesterday";
}
elseif ($daysListed < 1)
{
$days = "today";
}
which does a pretty good job, the main flaw i have with this is say my user submits a post at 23:59pm last night the above code will return a value of "today" because $datediff is returning less than 24 hours, even though it was posted yesterday. Is there a more accurate way of getting the correct value returned?
Appreciate your help Luke