发博时间计算
<?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('-25 month')); * echo iconv('utf-8', 'gb2312', $a->index())?iconv('utf-8', 'gb2312', $a->index()): iconv('utf-8', 'gb2312', '当前'); * */
以上就是发博时间计算的内容,更多相关内容请关注PHP中文网(www.php.cn)!
声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章
R.E.P.O.能量晶体解释及其做什么(黄色晶体)
2 周前By尊渡假赌尊渡假赌尊渡假赌
仓库:如何复兴队友
4 周前By尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
3 周前By尊渡假赌尊渡假赌尊渡假赌
击败分裂小说需要多长时间?
3 周前ByDDD
R.E.P.O.保存文件位置:在哪里以及如何保护它?
3 周前ByDDD

热工具

Dreamweaver CS6
视觉化网页开发工具

禅工作室 13.0.1
功能强大的PHP集成开发环境

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

Atom编辑器mac版下载
最流行的的开源编辑器