评论消息时间显示(刚刚,X分钟前,X小时前,X天前)

/**
         * 评论消息
         * @param $openid
         * @param $data
         */
        public function timeBefore($the_time)
        {
            $now_time = time();
            $dur = $now_time – $the_time;

            if ($dur < 0) {
                return $the_time;
            }

            if ($dur < 60) {
                return '刚刚';
            }

            if ($dur < 3600) {
                return floor($dur / 60) . '分钟前';
            }

            if ($dur < 86400) {
                return floor($dur / 3600) . '小时前';
            }

            if ($dur < 259200) {
                return floor($dur / 86400) . '天前';
            }

            return date('m-d', $the_time);
        }