Pastulio Posted June 14, 2007 Share Posted June 14, 2007 I have just written a Date Verification function for my form. The date entered by the user in the for is the date on which they Bought a certain product. Now The problems I'm having are the following: 1) I am using Language files, and I am unsure if I can use those globals withing a function. 2) What would be the best way for me to get specific error messages to the user. 3) Is there an easier way to do this, because it all seems a bit... farfetched. Here is the code to my function: (I also should mention that "ddMonth" is a global Array retrieved from the language file.) function checkDate ($day, $month, $year){ // Februari if ($month == $ddMonth[1]){ if ($day > 29){ return false; } elseif ($day == 29){ // Check if the entered year is a leapyear if ($year % 100 != 0 && ($year % 400 == 0 || $year % 4 == 0)){ return true; } else { return false; } } else { return true; } } // April if ($month == $ddMonth[3]){ if ($day > 30){ return false; } else { return true; } // June if ($month == $ddMonth[5]){ if ($day > 30){ return false; } else { return true; } // September if ($month == $ddMonth[8]){ if ($day > 30){ return false; } else { return true; } // November if ($month == $ddMonth[10]){ if ($day > 30){ return false; } else { return true; } } } Any help would be appreciated, thanks Quote Link to comment https://forums.phpfreaks.com/topic/55623-my-date-check-function-help/ Share on other sites More sharing options...
chigley Posted June 14, 2007 Share Posted June 14, 2007 What are you trying to achieve? $ddMonth doesn't appear to be defined anywhere either? Quote Link to comment https://forums.phpfreaks.com/topic/55623-my-date-check-function-help/#findComment-274851 Share on other sites More sharing options...
Pastulio Posted June 14, 2007 Author Share Posted June 14, 2007 Sorry about that, ddMonth is a Global array storing all of the values of months there are in various languages. ddMonth is actually the "dropdown" menu used in the form so ddMonth contains Januari Februari March ... December but the problem is in another language it's Januari Februari MAART (dutch) ... December Thus If I wasn't using this dropdown array, the values wouldn't always work out. And what I'm trying to archieve is wheter the date entered is a VALID date. Quote Link to comment https://forums.phpfreaks.com/topic/55623-my-date-check-function-help/#findComment-274853 Share on other sites More sharing options...
Pastulio Posted June 14, 2007 Author Share Posted June 14, 2007 *bump* Quote Link to comment https://forums.phpfreaks.com/topic/55623-my-date-check-function-help/#findComment-274869 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.