Reputation: 251
I have a column CMD_DATE in PhpMyAdmin (Varchar 16),
I want to have something like this :
23/09/2013 (so without the time)
How can i do it in PhpmyAdmin ? thanks
Upvotes: 0
Views: 173
Reputation: 423
I just wonder why do store date as a string. In my opinion, it is a better idea to revisit the design of your database and store a date as a date, if you can.
You can for example use foreach loop to read the old date value and insert the newly formatted value into a new field in each record and the best way to convert that string would be probably this:
date("Y-m-d", strtotime($string));
Or you can skip that and just use mysql's STR_TO_DATE() function.
UPDATE the_table
SET new_column = STR_TO_DATE(old_column, '%m/%d/%Y')
If you can't change the db, then when displaying you can remove the last 5 characters like this:
echo substr($string, 0, -5);
Then you will get this string: '23/09/2013'
Upvotes: 2