By default, PHPMyAdmin has the datetime column formatted as YYYY-MM-DD, but I'm trying to reformat it into MM-DD-YYYY using an SQL statement on my PHP file. This is the code I used, but it's not working:
<?php $usertext = $_POST['textinput']; $insertsql = "INSERT INTO testtext (usertext) VALUES ('$usertext')"; if (isset($_POST['textinput'])) { require '../db.php'; mysqli_query($db, $insertsql); } $selectdate = "SELECT textdate, DATE_FORMAT(textdate,'%m/%d/%Y') AS newdate FROM testtext"; $dateresult = mysqli_query($db, $selectdate); while ($row = mysqli_fetch_assoc($dateresult)) { echo "{$row['textdate']}<br>"; } ?> This code is able to display rows from the 'textdate' column onto my test site just fine, but the DATE_FORMAT code was unable to reformat the date. Can you please help me fix this code? Thanks so much.
$row['newdate']look like?