我只希望只寫出(Y)年份,如果只有它不是從當前年份開始。PHP:如果不是當前年份,寫出年份,時間戳
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;
}
}
`日期( 'Y',時間())`和`日期( 'Y')` – Ish 2011-01-13 20:30:04