PHP库生成用户友好的相对时间戳 [英] PHP library to generate user friendly relative timestamps

查看:106
本文介绍了PHP库生成用户友好的相对时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个PHP ,可以生成用户友好的时间表示,例如两小时前,当时间戳为 time() - 2 * 3600

I'm looking for a PHP library that generates user-friendly representations of times - for example "two hours ago" when the timestamp is time() - 2 * 3600.

有几个现有的问题与答案和博客文章( 2 3 ) ,但都只包含代码段 - 不能是我可以安装和升级的库。

There are several existing questions with answers and blog posts (1, 2, 3), but all only contain code snippets - not a library I can install and upgrade.

Django有一个,Python也有一个独立lib ,Javascript有几个( 1 2 3 ),PHP库在哪里?

Django has one, Python also has a standalone lib, Javascript has several (1, 2, 3), too - where is the PHP library?

图书馆应该具备以下内容:

A library should have the following things:


  • 文档

  • PEAR可安装

  • 定期发布

  • (可选) li>
  • documentation
  • PEAR installable
  • regular releases
  • (optional) translations

推荐答案

由于似乎没有图书馆,我自己做了一个它包含在PEAR中:

Since there didn't seem to be any library, I've made one myself and got it included in PEAR:

Date_HumanDiff http://pear.php.net/package/Date_HumanDiff

代码位于 http://github.com/pear/Date_HumanDiff

这篇关于PHP库生成用户友好的相对时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆