需求:我用的是MySQL.其中某表里面有时间:time字段,time字段存储的是1298354240,有什么办法获得最近3天的所有信息?

解决方案 »

  1.   

    要求用PHP代码写出来存到数组里面,请各位大侠,不吝赐教……
      

  2.   

    用 mktime 读出近三天的那个时间戳,然后sql时 >=时间戳就行了。没什么难道吧。
      

  3.   

    between吧,取出当天的时间戳与之前三天零点的时间戳,sql时加个between就行了
      

  4.   


    time_s = mktime() -  24 * 60 * 60*3;
    mysql_query('select * from table where order by time desc and time >'.time_s);
      

  5.   


    $time = strtotime('Ymd',time())-86400*3; //前三天零点时间戳
    $sql = "select * from table where time>$time order by time desc";
      

  6.   

    不用那么麻烦,直接:strtotime('-3 day')。
      

  7.   

    $comtime = strtotime(date("Y-m-d")." -3 days");
    $sql = "...where time>".$comtime." ...";
      

  8.   

    或者mysql计算...... where time > DATE_ADD(date(now()), INTERVAL -3 Day) ......
      

  9.   

    $dateline = sgmdate($_SGLOBAL['timestamp']-3600*24*7, 'Y-n-d');
    function sgmdate($timestamp, $dateformat='', $format=0) {
    global $_SCONFIG, $_SGLOBAL, $lang; if(empty($dateformat)) {
    $dateformat = 'Y-m-d H:i:s';
    }

    if(empty($timestamp)) {
    $timestamp = $_SGLOBAL['timestamp'];
    }

    $result = '';
    if($format) {
    $time = $_SGLOBAL['timestamp'] - $timestamp;
    if($time > 24*3600) {
    $result = gmdate($dateformat, $timestamp + $_SCONFIG['timeoffset'] * 3600);
    } elseif ($time > 3600) {
    $result = intval($time/3600).$lang['hour'].$lang['before'];
    } elseif ($time > 60) {
    $result = intval($time/60).$lang['minute'].$lang['before'];
    } elseif ($time > 0) {
    $result = $time.$lang['second'].$lang['before'];
    } else {
    $result = $lang['now'];
    }
    } else {
    $result = gmdate($dateformat, $timestamp + $_SCONFIG['timeoffset'] * 3600);
    }
    return $result;
    }