openlss/func-time

时间辅助函数

0.0.8 2013-03-27 03:34 UTC

This package is not auto-updated.

Last update: 2024-09-14 14:29:38 UTC


README

日期和时间函数

用法

$timestamp = time()-3600;
$ago = age($timestamp); //returns 1 hour

$timestamp = time()+3600
$in = future_age($timestamp); //returns 1 hour

$time = timestamp()-7200;
$hours = hours($time); //returns 2

参考

age($tm,$end=false)

  • $tm 要使用的戳记
  • $end 要使用的戳记作为 NOW,否则默认为 time()

future_age($tm,$end=false)

与 age() 具有相同的原型,但用于未来时间

hours($tm,$inc=1)

  • $tm 以秒为范围的值
  • $inc 增量,例如:2 = 每30分钟 返回 inc 次幂的小时数