我的MYSQL 里存储为datetime类型:date('Y-m-d   H:i:s') 如2009-07-01 15:31:04
现在我想通过JS控件取日期:2009-07-01类型, 然后与数据库中的时间时行比较, 该如何比较???

解决方案 »

  1.   

    public class dotime{
    private year;
    private month;
    private day;
    private hour;
    private second;
    private miao;
    function dotime($date){
    $data=explode(" ",$date);
    $datetime=$data[0];
    $datesec=$data[1];
    $detaildata=explode("-",$datetime);
    $detaildata1=explode(":",$datesec);
    $this->year=$detaildata[0];
    $this->month=$detaildata[1];
    $this->day=$detaildata[2];
    $this->hour=$detaildata1[0];
    $this->second=$detaildata1[1];
    $this->miao=$detaildata1[2];
    }
    function year(){
    return $this->year;
    }
    function month(){
    return $this->month;
    }
    function day(){
    return $this->day;
    }
    function hour(){
    return $this->hour;
    }
    function second(){
    return $this->second;
    }
    function miao(){
    return $this->miao;
    }
    }刚做了个封装类,改改就能用!
      

  2.   


    <?php
    $time = '2009-07-31';
    $start = $time.' 00:00:00';
    $end = date('Y-m-d',(strtotime($time)+3600*24)).' 00:00:00';
    $sql = 'select * from t where time>"'.$start.'" and time<"'.$end.'"';
    ?>PHP的话,我会这样写SQL语句
      

  3.   

    是PHP版内哦,呵呵..以为在MYSQL版了