Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Posts
    217
    Thanks
    1
    Thanked 0 Times in 0 Posts

    different date format validations ??

    hello forums!!
    can anybody give idea on different types of date format validation function like Y-m-d , dmY etc.
    example:
    PHP Code:
    function validateDate($input_date$format){
        
    //necessary processings....
        
    return bool;
    }
    validateDate('2008-08-135''Y-m-d'); 
    Thanks in advance for the valueable suggestions

  • #2
    Super Moderator JohnDubya's Avatar
    Join Date
    Nov 2006
    Location
    Missouri
    Posts
    634
    Thanks
    12
    Thanked 18 Times in 18 Posts
    Really, all you should need to do is break up the full date into parts (month, day, and year) and then use the checkdate() function that is built into PHP.

    FYI, to break up a full date, just use explode() with a delimiter of "-" or whatever is separating your date. explode() will send the date into an array with each value being a portion of your date. For instance:

    PHP Code:
    $full_date '2008-07-15';

    $date_array explode('-'$full_date);

    $year $date_array[0];
    $month $date_array[1];
    $day $date_array[2];

    if (
    checkdate($month$day$year)) {
       
    //continue with script

    Does that help?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •