Jump to content

Recommended Posts

ok i have a javascript calendar and the user selects the date ect ect and then it imputs it into mysql, well it inputs it like so. . . 11-APR-2009 and it uses short terms for the months how do i make a array or anything that will change the JAN,FEB,DEC,APR ect to the real month names before it is entered into mysql ?, thanks

 

James.

Link to comment
https://forums.phpfreaks.com/topic/153862-solved-php-date-help/
Share on other sites

Mysql DATE types are yyyy-mm-dd. Anything else makes for excess storage requirements, complicated queries and complicated presentation code, and slow queries.

 

You should probably explode your entered date format, convert the abbreviated month names into numbers using an array, then check for a valid date using checkdate, then format the parts into a yyyy-mm-dd format to put into your query.

Link to comment
https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808639
Share on other sites

Mysql DATE types are yyyy-mm-dd. Anything else makes for excess storage requirements, complicated queries and complicated presentation code, and slow queries.

 

You should probably explode your entered date format, convert the abbreviated month names into numbers using an array, then check for a valid date using checkdate, then format the parts into a yyyy-mm-dd format to put into your query.

 

ermmm im really confused :S, im not at all that good with php :S

 

would this be what you mean ?

 

<?php print_r(explode('-', $fromdat, 2)); ?>

Link to comment
https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808643
Share on other sites

Please do not spam saying something is urgent.  If it's so urgent, hire someone.

 

spam :S, what do you mean ?, i haven't spammed this thread ?

 

james, you have posted 3 times in less than 15 minutes, relax, be patient, and wait for a reply.  The more you bump post your thread, the less likely you'll get a response.

Link to comment
https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808644
Share on other sites

Please do not spam saying something is urgent.  If it's so urgent, hire someone.

 

spam :S, what do you mean ?, i haven't spammed this thread ?

 

james, you have posted 3 times in less than 15 minutes, relax, be patient, and wait for a reply.  The more you bump post your thread, the less likely you'll get a response.

 

hmmmm.... i guess your right, yea ok agreed sorry admin wont happen again.

Link to comment
https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808650
Share on other sites

lucky for you, strtotime seems to recognize your '11-APR-2009' format. 

 

$time = date('Y-m-d',strtotime('11-APR-2009'));

 

That will make it '2009-04-11' which is how you should be storing it in your db (as a column type date).  You would then use strtotime and date to format it the way you want when you display it.

Link to comment
https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808667
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.