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程序在IIS下运行正常,apache下出错 PHP如何实现下面的显示方式????? 自己做的验证码,能否被自动程序识别?(附:源文件) php5+Apache2+WinXp安装的问题。 问唠叨一个关于showModalDialog问题 一个低级问题 结果集能否通过session传递? 我在上传图片时遇到问题,见面,谢谢 为PHP悲乎? 正则表达式获取指定图片名的img标签 谁帮我下我。。。新人问题... 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;
}