Home > Backend Development > PHP Tutorial > PHP指定时间比较

PHP指定时间比较

WBOY
Release: 2016-06-23 13:56:11
Original
907 people have browsed it

数据库中时间由$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