찾다
php教程PHP源码发博时间计算

发博时间计算

May 25, 2016 pm 05:12 PM

发博时间计算

<?php
/*
 * author: Solon Ring
 * time: 2011-11-02
 * 发博时间计算(年,月,日,时,分,秒)
 * $createtime 可以是当前时间
 * $gettime 你要传进来的时间
 */
 
class Mygettime{
     
        function  __construct($createtime,$gettime) {
            $this->createtime = $createtime;
            $this->gettime = $gettime;
    }
 
    function getSeconds()
    {
            return $this->createtime-$this->gettime;
        }
 
    function getMinutes()
       {
       return ($this->createtime-$this->gettime)/(60);
       }
 
      function getHours()
       {
       return ($this->createtime-$this->gettime)/(60*60);
       }
 
      function getDay()
       {
        return ($this->createtime-$this->gettime)/(60*60*24);
       }
 
      function getMonth()
       {
        return ($this->createtime-$this->gettime)/(60*60*24*30);
       }
 
       function getYear()
       {
        return ($this->createtime-$this->gettime)/(60*60*24*30*12);
       }
 
       function index()
       {
            if($this->getYear() > 1)
            {
                 if($this->getYear() > 2)
                    {
                        return date("Y-m-d",$this->gettime);
                        exit();
                    }
                return intval($this->getYear())." 年前";
                exit();
            }
             
 
             if($this->getMonth() > 1)
            {
                return intval($this->getMonth())." 月前";
                exit();
            }
 
             if($this->getDay() > 1)
            {
                return intval($this->getDay())." 天前";
                exit();
            }
 
             if($this->getHours() > 1)
            {
                return intval($this->getHours())." 小时前";
                exit();
            }
 
             if($this->getMinutes() > 1)
            {
                return intval($this->getMinutes())." 分钟前";
                exit();
            }
 
           if($this->getSeconds() > 1)
            {
                return intval($this->getSeconds()-1)." 秒前";
                exit();
            }
 
             
       }
 
  }
 
 
/*
 *
 * 调用类输出方式
 *
 * $a = new Mygettime(time(),strtotime(&#39;-25 month&#39;));
 * echo iconv(&#39;utf-8&#39;, &#39;gb2312&#39;, $a->index())?iconv(&#39;utf-8&#39;, &#39;gb2312&#39;, $a->index()):
 iconv(&#39;utf-8&#39;, &#39;gb2312&#39;, &#39;当前&#39;);
 * 
 */

以上就是发博时间计算的内容,更多相关内容请关注PHP中文网(www.php.cn)!


성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
4 몇 주 전By尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

DVWA

DVWA

DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

Atom Editor Mac 버전 다운로드

Atom Editor Mac 버전 다운로드

가장 인기 있는 오픈 소스 편집기

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

SublimeText3 영어 버전

SublimeText3 영어 버전

권장 사항: Win 버전, 코드 프롬프트 지원!

ZendStudio 13.5.1 맥

ZendStudio 13.5.1 맥

강력한 PHP 통합 개발 환경