I m trying to change the date format in phpmyadmin. I m unable to change the format I want to change the format to dd-mmm-yyyy. How can I change the date format. Please help me
However, it's easy to change in PHP.
$myinput='2005/15/09'; $sqldate=date('d-m-Y',strtotime($myinput)); echo $sqldate;
Now 09-15-2005.
You can use phpMyAdmin's browser transformations feature to do this.
Structure page of the relevant table.Change hyperlink in the Actions column of the
relavent date/datetime/timestamp column.Text/Plain: Dateformat from the Browser Transformation
dropdown.0,'%d-%b-%Y','local' into the transformation options column.Browse page.From the documentation on Text/Plain: Dateformat transformation
Displays a
TIME,TIMESTAMP,DATETIMEor numeric unix timestamp column as formatted date. The first option is the offset (in hours) which will be added to the timestamp (default: 0). Use second option to specify a different date/time format string. Third option determines whether you want to see local date or UTC one (use"local"or"utc"strings) for that. According to that, date format has different value - for"local"see the documentation for PHP'sstrftime()function and for"utc"it is done usinggmdate()function.
It's not possible as far as I know. I stand corrected, see @Madhura Jayaratne's answer for how to change the date format using phpMyAdmin. However, if that's not available or you don't have permission, you can use the solution below to reformat it in PHP.
Let's say your $date_from_sql is set to 2014-03-23.
$date = date('d-m-Y', strtotime($date_from_sql)); //date format
Now $date equals 23-03-2014
Optionally you can wrap it in a function to use it throughout your application.
function fixdate($date) {
return date('d-m-Y', strtotime($date));
}
// When parsing data from the database:
$query = query("SELECT wrongdate FROM something")->result();
$date = fixdate($query->date);