嘿,大家看看这段代码。此代码显示当前月份的统计信息,但如果我想检查上个月的统计信息而不是本月,那么我需要在这个小代码中进行哪些更改?
$date_time_array = getdate(time());
$last_month = $date_time_array["month"];
$this_year = $date_time_array["year"];
$last_mon = $date_time_array["mon"];
$date = mktime(0,0,0,$last_mon,1,$this_year); //The get's the first of March 2009
$links = array();
$newstamp = time() - 3600;
$cpc = 0;
$cpm = 0;
$click = 0;
for($n=1;$n <= date('t',$date);$n++){
$thisdate = $this_year.'-'.$last_mon.'-'.str_pad($n, 2, '0', STR_PAD_LEFT );
$sql = "select * from pub_st_daily where user='$user' && STR_TO_DATE(pdate,'%Y-%m-%d') = '$thisdate' ";
答案 0 :(得分:0)
你可以这样做:
$date = new DateTime("07/30/2015"); //Will give you July 30th
$date_time_array=getdate($date->format("U"));
...