misheck Posted January 11, 2010 Share Posted January 11, 2010 I am developing a sample application and would like a user to have a drop down calendar and select a date from there. Does anyone have a work around on inserting a date into Mysql DATE column. My problem is at the moment I have been restricted to entering the date as 2009-01-02 but I am in the UK where we accustommed to entering the date as 02-01-2010. Is there a way I can modify mysql column to take the values that way? Quote Link to comment https://forums.phpfreaks.com/topic/188037-mysql-date/ Share on other sites More sharing options...
PravinS Posted January 11, 2010 Share Posted January 11, 2010 If data type of the date field is DATE or DATETIME then you can use DATE_FORMAT(date,format) function in your select query. Quote Link to comment https://forums.phpfreaks.com/topic/188037-mysql-date/#findComment-992687 Share on other sites More sharing options...
PFMaBiSmAd Posted January 11, 2010 Share Posted January 11, 2010 To take a date in any format consisting of numeric values for the year, month, and day and produce a YYYY-MM-DD format, it is generally fastest to do this - A) Separate the date into the individual year, month, and day values - explode B) Validate the date (everyone IS validating their user supplied data?) - checkdate C) Concatenate the individual parts with the '-' separator character to get the desired format. Quote Link to comment https://forums.phpfreaks.com/topic/188037-mysql-date/#findComment-992692 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.