title: Date format coming in weird way in CSV file using codeigniter
body: <p>I have a codeigniter function to create a CSV file for the user data from a DB.</p>
  
  <p>My function is this:-</p>
  
  <pre><code>function user_CSV()
  {
      $filename = 'CSV_User_Report.csv';      
      $this-&gt;load-&gt;dbutil();      
      $this-&gt;load-&gt;helper('file');        
      $this-&gt;load-&gt;helper('download');        
      $delimiter = ",";        
      $newline = "\r\n";  
      $queryUser = "SELECT user_name AS Name, 
                      user_username AS Username, 
                      user_mobile AS Mobile, 
                      DATE_FORMAT( user_added_date, '%d-%m-%Y' ) AS `Joining Date`,
                      DATE_FORMAT( user_last_activity, '%d-%m-%Y' ) AS `Last Acitivity`
                  FROM tbl_user"; 
      $dataResult = $this-&gt;db-&gt;query($queryUser);
      if($dataResult-&gt;num_rows()&gt;0)       
      {   
          $data = $this-&gt;dbutil-&gt;csv_from_result($dataResult, $delimiter, $newline);      
      }   
      if(force_download($filename, $data))        
      {           
          redirect('admin/user');     
      }
  }
  </code></pre>
  
  <p>Now, this one is creating the CSV file. But there is a severe issue. To illustrate that, I am sharing the screenshot of the CSV.
  <a href="https://i.stack.imgur.com/0gnV0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0gnV0.png" alt="enter image description here"></a></p>
  
  <p>As you can see, some of the Joining Date is coming in dd/m/YYYY format, and some dd-mm-YYYY format.</p>
  
  <p>But, when I am trying to see the query in phpmyadmin, I am getting the result like this:-
  <a href="https://i.stack.imgur.com/L0c23.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L0c23.png" alt="enter image description here"></a></p>
  
  <p>Why is such inconsistency of display of date format in CSV data?
  What am I doing wrong?</p>