Home > Backend Development > PHP Tutorial > 关于是时间戳对比的有关问题

关于是时间戳对比的有关问题

WBOY
Release: 2016-06-13 13:13:34
Original
904 people have browsed it

关于是时间戳对比的问题
在数据库中,我以时间戳存储数据(time())
现在我要使用如2012/8/22这样的日期去查询
但是遇到一个关于称数的问题
我该如何做才能查到找数据库中等于今天的这个所有数据呢?

------解决方案--------------------
SELECT * FROM tt WHERE FROM_UNIXTIME( time, '%Y/%m/%d' ) ='2012/8/22'
------解决方案--------------------
我建议你将"2012/8/22" 转换成时间戳 比如 N

搜索时间 between N and (N+86400-1)
------解决方案--------------------
$dated = strtotime($_GET['dateitme']);
qsj_magazine.datetime =$dated;
------解决方案--------------------
$dated = strtotime($_GET['dateitme']);
qsj_magazine.datetime =$dated;
------解决方案--------------------
$dated = strtotime($_GET['dateitme']);
qsj_magazine.datetime =$dated;
------解决方案--------------------

PHP code

$oldtime = '2012-8-22 23:59:59';  
$catime = strtotime($oldtime);
SELECT * FROM qsj_user_profile,qsj_magazine WHERE qsj_magazine.uid = qsj_user_profile.uid AND qsj_magazine.datetime > '$catime ';
<br><font color="#e78608">------解决方案--------------------</font><br>我都是将2012/8/22转换成时间戳,需要转换两个值,第一个是2012/8/22这天0点0分,第二个是<br>2012/8/23这天0点0分<br><br>然后再搜索time字段介于上面两个值之间
<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
PHP code

$oldtime = '2012-8-22 23:59:59';  
$catime = strtotime($oldtime);
SELECT * FROM qsj_user_profile,qsj_magazine WHERE qsj_magazine.uid = qsj_user_profile.uid AND qsj_magazine.datetime > '$catime '; <div class="clear">
                 
              
              
        
            </div>
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