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? 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. 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. Link to comment https://forums.phpfreaks.com/topic/188037-mysql-date/#findComment-992692 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.