How does PHP query by date

Source: Internet
Author: User
How PHP is queried by date
The field addtime in MySQL is timestamp
I need to query this now
Xx.php?u=20130328&page=1 &page= This is for paging.
So query 20130328 or 20130329 this day data


 Include ". /include/song.inc.php ";
$key = $_get[' u '];
if ($_get["page"]) {
$page =$_get["page"]; #获取要显示的页码
}else{
$page =1; #没有参数传入时, show first page
}
$col =20; #每页显示记录条数
$p = ($page-1) * $COL;
$RUNSQL = mysql_query ("select * from Cmsdj_song where uid = ' $key ' ORDER by ID ' desc limit '. $p.", ". $col.");
while ($row = Mysql_fetch_array ($RUNSQL))
{
Here are the call values
$sid = $row [' id '];
$suid = $row [' uid '];
$supip = $row [' Upip '];
$name = $row [' name '];
$sname =substr ($name, 0,30);
$sfile = $row [' file '];
$surl = $row [' url '];
$SWJDX = $row [' Wjdx '];
$stime =date (' y-m-d h:i:s ', $row [' addtime ']);
$b 64file=base64_encode ($surl);
?>













' > ' > ' > ' >

}
?>
$col =20; #每页显示记录条数
$count =mysql_query ("SELECT ID from Cmsdj_song where uid like '% $key% '"); #取得记录总条数
$num = mysql_num_rows ($count)/$col; #计算页数
$nnx = mysql_num_rows ($count); #计算页数
$num =ceil ($num); #无条件小数进位确定总页数
Mysql_close ();
?>


------Solution--------------------
From_unixtime () Unix timestamp converted to date
Unix_timestamp () date converted to UNIX timestamp
------Solution--------------------

$u = $_get[' u '];

$starttime = Strtotime ($u. ' 000000 ');
$endtime = strtotime ($u. ' 235959 ');

$RUNSQL = mysql_query ("select * from Cmsdj_song where addtime > ' $starttime ' and addtime< ' $endtime ' ORDER by id DESC Limit ". $p.", ". $col.");
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.