I wish to only write out(Y) the year, if only its not from the current year we’re on.
function get_day_name($timestamp) {
$date = date('j-m-Y', $timestamp);
if($date == date('j-m-Y')) {
$day_name = 'Today';
echo 'idag ';
} else if($date == date('j-m-Y',time() - (24 * 60 * 60))) {
$day_name = 'Yesterday';
echo 'igår ';
}else{
# How can i check here whether the $timestamp is from this year or last year?
# If it is from this year then it shouldnt write out the "Y" in $date
echo $date;
}
}
Based on the comment in your original post
I thought you were asking how you could check to see if the timestamp year was from this year or last year. So, I thought you meant you wanted to know, for example, if the year was 2011 or 2010. What you really want to know is whether the timestamp year is from this year, or any other year, be it 2010, 2009, etc.
This was my first answer, based on my misunderstanding…
This is how you would want to do it: