php时间戳获取全年记录 从option中 获取到某年的值2011~2020mysql是时间戳格式,请问 怎么截取值中的全年时间戳? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我知道用strtotime()转换成时间戳但是 我的sql语句怎么写啊??这个转换的只是一个时间戳,但是 我想获得的是一整年。。? 是要查询 option选择要查询哪年的选择后 会给后台一个值比如是2011到后台后 strtotime()可以把2011选换成时间戳但是 怎么从数据库里面读出2011年所有记录?就是从2011年初到年末的所有值数据库里面 也是时间戳格式 时间戳直接比较select xxxx from xxxx where xxx <endtime and xxx >startime. select * from tbl_name where FROM_UNIXTIME(字段,'%Y')='$year' 前台<form action="1.php" method="post"><select name="radio"> <option value="all">全部时间</option> <?php for($i=2011;$i<=2030;$i++) { ?> <option value="<?=$i?>"><?=$i?></option> <?php } ?></select><input type="submit" value="提交" /></form>后台<?php$radion=$_POST["radio"];if($radion=="all"){ echo "全部时间";}else{ $timeall=strtotime($radion); echo $timeall; $where_string="select * from tbs_index_affiche where FROM_UNIXTIME(addDateTime,'%Y')='$timeall'";}?>mysql的时间戳存在addDateTime中不是很了解FORM_UNIXTIME语句,这个语句显示不出来啊。。 $begintimeall=$radio."-01-01";$endtimeall=$radio."-12-31";strtotime($begintimeall);strtotime($endtimeall);"where name between 起始时间 and 结束时间; select * from tbl_name where 字段 like '$year%' 时间戳,不是时间格式,所以like '$year'是行不通的。推荐版主的from_unixtime()这种方法。 php实现帖子水军脚本 数据库按时更新的问题 要新建一个数据库,如何先判断下是否已存在? 如何实现这个???求助! 获取地址的问题 PHP中通过正则查找字符串 断点续传 急求PHP导出表格到EXCEL!!!!!!! 你们说查到与没查到返回多少? ajax返回字符串为什么开头会有空格 用其他帐号(比如QQ msn)登录自己的网站,需要怎么做呀?? 请问哪个免费的 第三方网站访问量统计,比较好,并且有总访问量的数字显示?
但是 我的sql语句怎么写啊??
这个转换的只是一个时间戳,但是 我想获得的是一整年。。?
选择后 会给后台一个值
比如是2011
到后台后 strtotime()可以把2011选换成时间戳
但是 怎么从数据库里面读出2011年所有记录?就是从2011年初到年末的所有值
数据库里面 也是时间戳格式
时间戳直接比较select xxxx from xxxx where xxx <endtime and xxx >startime.
<select name="radio">
<option value="all">全部时间</option>
<?php
for($i=2011;$i<=2030;$i++)
{
?>
<option value="<?=$i?>"><?=$i?></option>
<?php
}
?>
</select>
<input type="submit" value="提交" />
</form>
后台<?php
$radion=$_POST["radio"];
if($radion=="all")
{
echo "全部时间";
}
else
{
$timeall=strtotime($radion);
echo $timeall;
$where_string="select * from tbs_index_affiche where FROM_UNIXTIME(addDateTime,'%Y')='$timeall'";
}
?>
mysql的时间戳存在addDateTime中
不是很了解FORM_UNIXTIME语句,这个语句显示不出来啊。。
$begintimeall=$radio."-01-01";
$endtimeall=$radio."-12-31";strtotime($begintimeall);
strtotime($endtimeall);
"where name between 起始时间 and 结束时间;
推荐版主的from_unixtime()这种方法。