Home > Backend Development > PHP Tutorial > PHP指定时间比较解决办法

PHP指定时间比较解决办法

WBOY
Release: 2016-06-13 11:58:31
Original
873 people have browsed it

PHP指定时间比较

本帖最后由 jaredlong 于 2014-05-30 13:16:57 编辑 数据库中时间由$row['olex']取得。
现在要比较这个变量取得的时间和当前时间的7天前时间大小关系,请问该怎么写呢。
注:数据库中时间字段的值格式为   2014-05-22  17:16:15
------解决方案--------------------
echo strtotime($row['olex']) > strtotime('-7 day') ? '7天内' : '很早了';
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template