Results 1 to 4 of 4

Thread: Checking if a date is valid -[RESOLVED]-

  1. #1

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349

    Resolved Checking if a date is valid -[RESOLVED]-

    How can I check if a date exists? I imagine php has a function for this but I don't know its name .
    Last edited by Electroman; Jan 5th, 2005 at 08:41 PM.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  2. #2
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802

    Re: Checking if a date is valid

    From the PHP manual. Is it good enough or do you need a better check?
    checkdate

    (PHP 3, PHP 4 , PHP 5)
    checkdate -- Validate a Gregorian date
    Description
    bool checkdate ( int month, int day, int year)

    Returns TRUE if the date given is valid; otherwise returns FALSE. Checks the validity of the date formed by the arguments. A date is considered valid if:
    * year is between 1 and 32767 inclusive
    * month is between 1 and 12 inclusive
    * Day is within the allowed number of days for the given month. Leap years are taken into consideration.

    Example 1. checkdate() example
    <?php
    var_dump(checkdate(12, 31, 2000));
    var_dump(checkdate(2, 29, 2001));
    ?>

    The above example will output:

    bool(true)
    bool(false)
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  3. #3

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349

    Re: Checking if a date is valid

    Perfect thanx .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  4. #4
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802

    Re: Checking if a date is valid -[RESOLVED]-

    No problem.
    I'm glad I could help you for a change
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

Posting Permissions

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



Click Here to Expand Forum to Full Width