还剩多长时间过期
public function TimeToSeconds( $end_time )
{
date_default_timezone_set('Asia/Shanghai');
$now = time();
$expires_in = $end_time;
$expires = $expires_in - $now;
if( $expires > 0 )
{
$seconds = (int)$expires;
if( $seconds < 60 )
{
$format_time = gmstrftime('%S秒' , $seconds);
}
elseif( $seconds < 3600 )
{
$format_time = gmstrftime('%M分%S秒' , $seconds);
}
elseif( $seconds < 86400 )
{
$format_time = gmstrftime('%H时%M分%S秒' , $seconds);
}
else
{
$time = explode(' ' , gmstrftime('%j %H %M %S' , $seconds));//Array ( [0] => 04 [1] => 14 [2] => 14 [3] => 35 )
$format_time = ( $time[0] - 1 ) . '天' . $time[1] . '时' . $time[2] . '分' . $time[3] . '秒';
}
return ltrim($format_time,0);
}
else
{
return 0;
}
}
网友评论