PHP送分题:时间查询的问题 需求:我用的是MySQL.其中某表里面有时间:time字段,time字段存储的是1298354240,有什么办法获得最近3天的所有信息? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 要求用PHP代码写出来存到数组里面,请各位大侠,不吝赐教…… 用 mktime 读出近三天的那个时间戳,然后sql时 >=时间戳就行了。没什么难道吧。 between吧,取出当天的时间戳与之前三天零点的时间戳,sql时加个between就行了 time_s = mktime() - 24 * 60 * 60*3;mysql_query('select * from table where order by time desc and time >'.time_s); $time = strtotime('Ymd',time())-86400*3; //前三天零点时间戳$sql = "select * from table where time>$time order by time desc"; 不用那么麻烦,直接:strtotime('-3 day')。 $comtime = strtotime(date("Y-m-d")." -3 days");$sql = "...where time>".$comtime." ..."; 或者mysql计算...... where time > DATE_ADD(date(now()), INTERVAL -3 Day) ...... $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;} php文件怎么编辑?(初学者) 很奇怪的编码问题!大家来看! php中文输出英文的问题,在线等 国外数据库连接报错 请教一个显示“请等待”的问题 转编码时 dreamweaver 把中文保存成了问号 怎么办? WIN2000下配置采用微米天空套件配置PHP+MYSQL+CQI环境,为什么IIS连接不上了?如何恢复IIS呢? 怎样做一个这样的计算器?? 【求助】zend studio使用xdebug调试,一直停在57%进行不下去 要做一个类似的投票页面,请进来给点思路。谢谢大家。 谁帮我下我。。。新人问题... PHP关于断点续传的问题!求助!
time_s = mktime() - 24 * 60 * 60*3;
mysql_query('select * from table where order by time desc and time >'.time_s);
$time = strtotime('Ymd',time())-86400*3; //前三天零点时间戳
$sql = "select * from table where time>$time order by time desc";
$sql = "...where time>".$comtime." ...";
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;
}