Welcome Guest, Not a member yet? Register   Sign In
Dates showing up wrong on 31st of the month.
#1

Hi all,

This section has been working fine for a while but I have looked at it today on my test server and I noticed that it is broken and I have no idea why.

Here is my function:

PHP Code:
   public function get_month_page_views($month_num$total false$column){
 
   $pm = (int) date('n'strtotime($month_num));
 
   $pmy = (int) date('Y'strtotime($month_num)); 
 
   $this->db->select('*');
 
   $this->db->from('analytics_page_views');
 
   $this->db->where('MONTH(date)'$pm);
 
   $this->db->where('YEAR(date)'$pmy);
 
   if ($total == 'true'){
 
   $this->db->select_sum($column);
 
   }
 
   $query $this->db->get();
 
   if ($total == 'true'){
 
   return $query->row();
 
   } else {
 
   return $query->result();    
    
}
 
   
  


And I am using this to get the last 5 months statistics like : 

PHP Code:
$data['last_month_views'] = $this->Analytics_model->get_month_page_views('-1 months'true'page_hits'); 

now as of the 31st of May the last 5 months dates are showing as :

1:2017-05-01 00:00:00
2:2017-03-01 00:00:00
3:2017-03-01 00:00:00
4:2017-01-01 00:00:00
5:2016-12-01 00:00:00


I cannot for the life of me figure out why its pulling March for both -1 months and -2 months and then messing up for the remained.  Can anyone see an issue with this?
Reply


Messages In This Thread
Dates showing up wrong on 31st of the month. - by doomie22 - 05-31-2017, 03:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB