Jump to content

Recommended Posts

If User insert date like 12-dec-2008

 

insert into test values(1,'12-Dec-2008');

it gives error

ERROR 1292 (22007): Incorrect datetime value: '12-Dec-2008' for column 'todate'

at row 1

please help in this

 

I know mysql date format like 2008-12-12 . but i need '12-Dec-2008' convert to  2008-12-12 this

 

 

Link to comment
https://forums.phpfreaks.com/topic/137817-date-format-help/
Share on other sites

I suggest doing it through php.  You're supposed to be validating user input anyways.  For instance, if you're allowing the user to enter in the date from a text field, STR_TO_DATE() is not going to do you a whole lot of good if user entered in something other than a date, or some weird date format that these built in functions don't recognize.  Validate user input through php, send it to the db in the proper format.

 

 

And please do not post multiple topics asking the same thing.

Link to comment
https://forums.phpfreaks.com/topic/137817-date-format-help/#findComment-720317
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.