jamesxg1 Posted April 13, 2009 Share Posted April 13, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/153862-solved-php-date-help/ Share on other sites More sharing options...
jamesxg1 Posted April 13, 2009 Author Share Posted April 13, 2009 please there must be someone who knows how to do this ? Quote Link to comment https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808621 Share on other sites More sharing options...
jamesxg1 Posted April 13, 2009 Author Share Posted April 13, 2009 please someone, this is so urgent :S Quote Link to comment https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808630 Share on other sites More sharing options...
.josh Posted April 13, 2009 Share Posted April 13, 2009 Please do not spam saying something is urgent. If it's so urgent, hire someone. Quote Link to comment https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808635 Share on other sites More sharing options...
jamesxg1 Posted April 13, 2009 Author Share Posted April 13, 2009 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808638 Share on other sites More sharing options...
PFMaBiSmAd Posted April 13, 2009 Share Posted April 13, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808639 Share on other sites More sharing options...
jamesxg1 Posted April 13, 2009 Author Share Posted April 13, 2009 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)); ?> Quote Link to comment https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808643 Share on other sites More sharing options...
Maq Posted April 13, 2009 Share Posted April 13, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808644 Share on other sites More sharing options...
.josh Posted April 13, 2009 Share Posted April 13, 2009 You started a thread. About 7 minutes later, you post again. About 7 minutes later, you post again. That's called spamming. Quote Link to comment https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808645 Share on other sites More sharing options...
jamesxg1 Posted April 13, 2009 Author Share Posted April 13, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808650 Share on other sites More sharing options...
jamesxg1 Posted April 13, 2009 Author Share Posted April 13, 2009 You started a thread. About 7 minutes later, you post again. About 7 minutes later, you post again. That's called spamming. i know i see your point, i am sorry, it wont happen again, trust me i have taken that into account Quote Link to comment https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808653 Share on other sites More sharing options...
.josh Posted April 13, 2009 Share Posted April 13, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808667 Share on other sites More sharing options...
jamesxg1 Posted April 13, 2009 Author Share Posted April 13, 2009 i get 1970-01-01 in the DB when i select 11-APR-2009 on the calender :S Quote Link to comment https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808675 Share on other sites More sharing options...
PFMaBiSmAd Posted April 13, 2009 Share Posted April 13, 2009 Your actual code must be doing something wrong, because that date/strtotime code works form me with that format. What have you done to debug at what point the data in your variables is correct and at what point it is not? Quote Link to comment https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808691 Share on other sites More sharing options...
jamesxg1 Posted April 13, 2009 Author Share Posted April 13, 2009 i got it working .. . . . it was. . . $date = date('Y-m-d',strtotime('$date')); changed to $date = date('Y-m-d',strtotime("$date")); and it works , cheers mate your a star(*) Quote Link to comment https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808697 Share on other sites More sharing options...
.josh Posted April 13, 2009 Share Posted April 13, 2009 yeah..single quotes around a variable will not parse the variable. It will be interpreted literally. Double quotes will parse it. But FYI you don't need to have the quotes at all, since it's a variable. Quote Link to comment https://forums.phpfreaks.com/topic/153862-solved-php-date-help/#findComment-808703 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.