PHP头条
热点:

php本月、下月时间


php 本月、上月时间
这种可以得到本日的时间
$sqljrfw="select ttotal from total_number where to_days(tdate) = to_days(now())";
这个tdate是一个时间字段类型是2012-08-16这种类型,那么我怎么才能得到这个08月的所有数据呢?还有08月的上一个月的数据?

------解决方案--------------------
date_format(tdate,'%Y-%m') = '年-月'

年月为你需要的值
------解决方案--------------------
sorry,搞错了,忘记考虑年份了。改成下面试试:
当月:select ttotal from total_number where date_format(tdate,"%Y-%m") = date_format(now(),"%Y-%m")
上月: select ttotal from total_number where date_format(tdate,"%Y-%m") = date_format(date_sub(now(),interval 1 month),"%Y-%m")

www.phpzy.comtrue/phprm/36228.htmlTechArticlephp本月、下月时间 php 本月、上月时间 这种可以得到本日的时间 $sqljrfw="select ttotal from total_number where to_days(tdate) = to_days(now())"; 这个tdate是一个时间字段类型是2012-08-16这种类型,那么我...

相关文章

PHP之友评论

今天推荐