时间日期能够使用比较运算符吗?

WBOY
Release: 2016-07-06 13:53:58
Original
901 people have browsed it

下面的代码能够返回"true"或"false"吗?

<code>$time<=date("Y-m-d-H-i-s")</code>
Copy after login
Copy after login

我编了一个短信发送的代码,作用是检索数据库,如果预定发送时间早于当前时间,就发送短信。
如果上面的代码不能起作用,请推荐一个方法,谢谢!
(初学者,问题可能有些白痴,请耐心回答,谢谢)

回复内容:

下面的代码能够返回"true"或"false"吗?

<code>$time<=date("Y-m-d-H-i-s")</code>
Copy after login
Copy after login

我编了一个短信发送的代码,作用是检索数据库,如果预定发送时间早于当前时间,就发送短信。
如果上面的代码不能起作用,请推荐一个方法,谢谢!
(初学者,问题可能有些白痴,请耐心回答,谢谢)

<code class="php">//可以,不过可以用strtotime转化比较
>>> $time=date('Y-m-d H:i:s')
=> "2016-06-10 13:39:38"
>>> $time >='2016-06-09 11:11:11'
=> true
>>> $time>='2016-06-19 11:11:11'
=> false
>>> strtotime($time)>=strtotime('2016-06-19 11:11:11')
=> false</code>
Copy after login

字符串可以比较大小么。。。

strottime() 可以吧

不应该是时间戳比较嘛

Related labels:
php
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!