1.时间转换成天,时,分,秒

/**
     * 将秒时间转换成天 小时 分 秒
     * @author mmy
     * @param $second
     * @return string
     */
    function time2string($second)
    {
        $day = floor($second/(3600*24));
        $second = $second%(3600*24);
        $hour = floor($second/3600);
        $second = $second%3600;
        $minute = floor($second/60);
        $second = $second%60;

        if(empty($day)&&empty($hour)&&empty($minute)&&!empty($second))
        {
            return $second.'秒';
        }
        elseif(empty($day)&&empty($hour)&&!empty($minute)&&!empty($second))
        {
            return $minute.'分'.$second.'秒';
        }elseif(empty($day)&&!empty($hour)&&!empty($minute)&&!empty($second))
        {
            return $hour.'小时'.$minute.'分'.$second.'秒';
        }elseif(!empty($day)&&!empty($hour)&&!empty($minute)&&!empty($second))
        {
            return $day.'天'.$hour.'小时'.$minute.'分'.$second.'秒';
        }
    }

2.获取客户端真实ip

    /**
     * 获取客户端远程ip
     * @author mmy
     * @return string
     */
    public function getRemoteIp()
    {
        if (getenv("HTTP_CLIENT_IP"))
            $clientIp = getenv("HTTP_CLIENT_IP");
        else if(getenv("HTTP_X_FORWARDED_FOR"))
            $clientIp = getenv("HTTP_X_FORWARDED_FOR");
        else if(getenv("REMOTE_ADDR"))
            $clientIp = getenv("REMOTE_ADDR");
        else
            $clientIp = "Unknow";

        return $clientIp;
    }

mmy123456
376 声望17 粉丝

有项目请联系:15201970281(毛毛)