I have a script that outputs 'Today' or 'Yesterday' for the date a piece of content was posted but if its the first of the month yesterday don't work.
Is there a way to subtract one day from the date variable, the below code I'm using at the moment is:
Is there a way to subtract one day from the date variable, the below code I'm using at the moment is:
Code:
if(date("dmY") == date("dmY", strtotime($datetimeIn)))
$datetime = 'Today @ '.date("H:i", strtotime($datetimeIn));
else if((date("d")-1).date("mY") == date("dmY", strtotime($datetimeIn)))
$datetime = 'Yesterday @ '.date("H:i", strtotime($datetimeIn));
else
$datetime = date("D jS, F Y @ H:i", strtotime($datetimeIn));
Comment