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 ?
My code is here
<?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);
?>