/*

* author: china_skag

* time: 2014-07-08

* 发博时间计算(年,月,日,时,分,秒)

* $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 多长时间前,php 多长时间之前 的函数相关推荐

  1. Java获取当前时间前10分钟的时间

    Date now = new Date(); Date now_10 = new Date(now.getTime() - 600000); //10分钟前的时间 SimpleDateFormat d ...

  2. java得到某时间前2小时的时间

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar calendar = Ca ...

  3. python获取服务器系统时间,Python datetime获取详细时间

    说明:datetime是date和time的结合体,包含了date和time的所有信息 datetime常见用法: 1.datetime.datetime.now()返回一个UTC时间的datetim ...

  4. linux 查看mysql运行时间_linux – strace显示从mysql socket读取很长时间 – mysql需要很长时间才能执行查询?...

    我的Apache服务器需要很长时间来处理请求.我附上了strace,可以看到以下两个延迟: 1)非常关键(处理143秒) 1335 0.000037 write(16, "\235\0\0\ ...

  5. mysql时长用什么类型_MySQL 日期时间类型怎么选?千万不要乱用!

    构建数据库写程序避免不了使用日期和时间,对于数据库来说,有多种日期时间字段可供选择,如 timestamp 和 datetime 以及使用 int 来存储 unix timestamp. 不仅新手,包 ...

  6. python自学时间-Python学习周期多长,老男孩学习多长时间?

    学习Python是不少人的选择,而且Python现在市场上发展是非常好的,可以说是成为了不少人的梦想吧.学习Python语言在初期入门阶段的时候,我们就可以动手做小项目了,这样会增进很多人学习的热情, ...

  7. Python获取主机信息、开机时间和开机时长、当前登陆用户

    题目描述: 1.获取当前主机信息(操作系统名.主机名.内核版本.硬件架构) 2.获取开机时间和开机时长 3.获取当前登录用户 代码块: import os import psutil from dat ...

  8. 计算机软件考试考几天,【软考考试时间是多久?软考时间有多长?】- 环球网校...

    [摘要]环球网校分享的软考考试时间是多久?软考时间有多长?相关答疑,以下介绍了软考考试时间安排希望对大家有帮助,,更多资料敬请关注环球软考考试频道,网校会及时更新考试相关资讯-- 相关推荐:各 [摘要 ...

  9. 马上6等待服务器响应,解决网页响应慢,等待时间过长,waiting(TTFB)时间过长...

    本次是玩客云新装的一个系统,系统的DNS没换过,然后内网搭建了一个网站,发现网站访问时响应时间过长. 一个网页加载18秒钟,查阅了大量关于TTFB的文章,我排除了网速原因,后来又排除了PHP原因,后面 ...

最新文章

  1. 漫谈视频目标跟踪与分割
  2. opencv_IplImage未定义的标识符解决
  3. LeetCode 1727. 重新排列后的最大子矩阵(前缀和+排序)
  4. mac安装python环境教程_python mac下安装虚拟环境的图文教程
  5. 计算机专业英语第07章,计算机专业英语电子教案第07章.ppt
  6. 感谢相信你鼓励你的人
  7. linux进程作为服务,将一个监视进程做成linux系统服务
  8. 我理解的Future模式
  9. 看了这份《算法中文手册》笔记,就再也不怕字节了~
  10. 文件app如何连接服务器,如何实现app与服务器连接数据库
  11. 大小端详解(判断+转换)
  12. PLC控制系统设计的基本内容
  13. 商城项目测试用例设计实战
  14. 交换机端口mtu值最大_思科交换机基本配置命令全集-mtu值怎么设置
  15. 脉冲神经网络(SNN)论文阅读(一)-----Going Deeper With Directly-Trained Larger Spiking Neural Networks
  16. 寂寞与孤独是人生中两大财富
  17. 视觉导航路径编辑器使用教程
  18. 汪峰演唱会的线上营销和线下营销
  19. P14-前端基础-CSS属性选择器
  20. 360篡改主页如何恢复

热门文章

  1. 面试:说说你对 HashMap 的认识?
  2. 京东技术主导:全新架构的分布式事务Hmily 2.1.1发布
  3. 每日一皮:键盘未找到的窘境...
  4. 每日一皮:资深老鸟看实习生写代码...
  5. centos 7 如何验证oracle安装成功_linux下Oracle数据的安装详解
  6. Google Colab 使用教程(1)
  7. url 百分号 解码
  8. CentripetalNet 48
  9. SIGGRAPH2018黑科技:开源语义软分割改进图像编辑
  10. git submodule 删除及更新URL