This question already has an answer here:
- Convert to date format dd/mm/yyyy 6 answers
In mysql data base the date is f=stored in the format of now() function like yyyy mm dd hh mm ss. But in frontend tool i want it like dd mm yyyy hh mm ss how can i convert it.
<?php
$addqry=mysql_query("INSERT INTO `exam` (`user_id`,`sub_id`,`q_id`,`stud_ans`,`date_time`)VALUES ('$user', '$sub', '$ans', '$stud_ans',(Now()))");
$stud_ans=' ';
if($addqry)
{
//result
$date;
$last_date=mysql_query("SELECT date_time FROM exam ORDER BY id DESC LIMIT 1; ");
while($res_last=mysql_fetch_array($last_date))
{
$date=$res_last['date_time'];
}
?>
Here it gives the datetime in the format of 2014-04-12 15:34:40 but i want it like 12-04-2014 15:34:40
</div>