|
-
Jan 5th, 2005, 07:10 PM
#1
Thread Starter
Ex-Super Mod'rater
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.

-
Jan 5th, 2005, 07:34 PM
#2
Fanatic Member
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
-
Jan 5th, 2005, 08:40 PM
#3
Thread Starter
Ex-Super Mod'rater
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.

-
Jan 5th, 2005, 09:13 PM
#4
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|