title: How to set $variable as a DATE_FORMAT in MySQL
body: <p>I have created one variable for changing date format in MySQL query but it is not working for me so is there any way to use a variable as a date-format in MySQl query ? </p>
  
  <p>My code is here</p>
  
  <pre><code>&lt;?php
      $con = mysql_connect();
      mysql_select_db();
      $dateFormat = '%d-%m-%Y';
      $result = mysql_query("SELECT *, DATE_FORMAT(2014-11-18, $dtFormat) AS niceDate FROM TableName;");
      $data = array();
      while ( $row = mysql_fetch_row($result, true) )
      {
          $data[] = $row;    
      }
      echo json_encode($data);
  ?&gt;
  </code></pre>