public static function dateToText($timestamp = 0) {
$group = '';
$timestamp = strtotime(date("Y-m-d",$timestamp));
$diff = ceil(($timestamp - time()) / (24 * 60 * 60));
if ($diff > 0) {
if ($diff == 1)
$group = "明天";
else if ($diff == 2)
$group = "后天";
else if (($diff > 2) && (date("W", $timestamp) == date("W", time())) && ($diff <= -7))
$group = "本周" . str_replace(array("0", "1", "2", "3", "4", "5", "6"), array("日", "一", "二", "三", "四", "五", "六"), date("w", $timestamp));
else if ($diff <= 7)
$group = "下周" . str_replace(array("0", "1", "2", "3", "4", "5", "6"), array("日", "一", "二", "三", "四", "五", "六"), date("w", $timestamp));
else
$group = date("Y-m-d", $timestamp);
}else if ($diff < 0) {
if ($diff == -1)
$group = "昨天";
else if ($diff == -2)
$group = "前天";
else if (($diff < -2) && (date("W", $timestamp) == date("W", time())) && ($diff > -7))
$group = "本周" . str_replace(array("0", "1", "2", "3", "4", "5", "6"), array("日", "一", "二", "三", "四", "五", "六"), date("w", $timestamp));
else if ($diff >= -7)
$group = "上周" . str_replace(array("0", "1", "2", "3", "4", "5", "6"), array("日", "一", "二", "三", "四", "五", "六"), date("w", $timestamp));
else
$group = "更早";
}else {
$group = "今天";
};
return CHtml::tag("span", array("class" => "label label-info"), $group);
}
$group = '';
$timestamp = strtotime(date("Y-m-d",$timestamp));
$diff = ceil(($timestamp - time()) / (24 * 60 * 60));
if ($diff > 0) {
if ($diff == 1)
$group = "明天";
else if ($diff == 2)
$group = "后天";
else if (($diff > 2) && (date("W", $timestamp) == date("W", time())) && ($diff <= -7))
$group = "本周" . str_replace(array("0", "1", "2", "3", "4", "5", "6"), array("日", "一", "二", "三", "四", "五", "六"), date("w", $timestamp));
else if ($diff <= 7)
$group = "下周" . str_replace(array("0", "1", "2", "3", "4", "5", "6"), array("日", "一", "二", "三", "四", "五", "六"), date("w", $timestamp));
else
$group = date("Y-m-d", $timestamp);
}else if ($diff < 0) {
if ($diff == -1)
$group = "昨天";
else if ($diff == -2)
$group = "前天";
else if (($diff < -2) && (date("W", $timestamp) == date("W", time())) && ($diff > -7))
$group = "本周" . str_replace(array("0", "1", "2", "3", "4", "5", "6"), array("日", "一", "二", "三", "四", "五", "六"), date("w", $timestamp));
else if ($diff >= -7)
$group = "上周" . str_replace(array("0", "1", "2", "3", "4", "5", "6"), array("日", "一", "二", "三", "四", "五", "六"), date("w", $timestamp));
else
$group = "更早";
}else {
$group = "今天";
};
return CHtml::tag("span", array("class" => "label label-info"), $group);
}