tribal Posted October 23, 2003 Share Posted October 23, 2003 hi, i got a DB field that is a DATETIME format and is automatically entered when a user registers. how do i change format from 2003-10-22 10:05:06 to something like 10/22/2003 10:05 ?? can i modify the existing mysql format? Quote Link to comment Share on other sites More sharing options...
nabeel21 Posted October 24, 2003 Share Posted October 24, 2003 From MySQL manual: MySQL retrieves and displays DATETIME values in \'YYYY-MM-DD HH:MM:SS\' format. I had the same issue and wanted to store the date in mysql in a custom format. I defined the column to be a TEXT instead of DATETIME and populated it with PHP [php:1:44d99b4a40]<?php $datetime = date(\"d/m/Y h:i\"); ?>[/php:1:44d99b4a40] Hope it helps. Quote Link to comment Share on other sites More sharing options...
Barand Posted October 25, 2003 Share Posted October 25, 2003 ... and in doing so. lost the ability to sort it into sequence, use comparison operators or use any of the dozens of date/time functions provided. Leave it as it is in the database and format it on output. Quote Link to comment Share on other sites More sharing options...
jwk811 Posted May 2, 2008 Share Posted May 2, 2008 I was searching the same problem. I would like to change it on output but i can't find any functions that will do that. They only format the time as it is now. I want to take any date from the DATE on mysql and change it to eg. Jan. 11, 2005 .. can anyone help me find a function that will do this, thanks! Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 2, 2008 Share Posted May 2, 2008 Use the mysql DATE_FORMAT() function in your query, you can find it in the date and time function section of the mysql manual. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.