Xav*_*ier 1 php comparison timestamp date
echo ($timestamp) 给 "2012-05-03 15:35:46"
PHP命令会是什么样的:"if $timestamp is older than 12 weeks then…"
谢谢你的帮助!
Dav*_*ger 15
这是在微优化方面在PHP中实现它的最快方法.
if(strtotime($timestamp) <= time() - (60*60*24*7*12)){
// 60 secs * 60 mins * 24 hours * 7 days * 12 weeks
}
Run Code Online (Sandbox Code Playgroud)
请阅读有关strtotime的内容,了解如何将时间戳转换为unixtime.另请阅读时间功能.
你需要的是什么strtotime()!
$timestamp = strtotime($timestamp);
$twelveWeeksAgo = strtotime('-12 weeks');
if($timestamp < $twelveWeeksAgo) {
// do something
}
Run Code Online (Sandbox Code Playgroud)
有多种方法可以检查这一点,这是最明显的解释恕我直言.
| 归档时间: |
|
| 查看次数: |
5105 次 |
| 最近记录: |