Current location: Hot Scripts Forums » Programming Languages » PHP » PHP Function to find if a variable is a valid date?


PHP Function to find if a variable is a valid date?

Reply
  #1 (permalink)  
Old 11-01-04, 09:56 PM
jozin jozin is offline
Newbie Coder
 
Join Date: Oct 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Function to find if a variable is a valid date?

Hello to everyone,

Is there a built-in function in PHP to validate if the entered value is a valid date? Like, is_number()?

Thanks a lot in advance.

jozin
Reply With Quote
  #2 (permalink)  
Old 11-01-04, 10:12 PM
moronovich moronovich is offline
Junior Code Guru
 
Join Date: Oct 2004
Posts: 460
Thanks: 0
Thanked 0 Times in 0 Posts
simply use (bool) checkdate($givenMonth,$givenDay,$givenYear)
it's all that you need.

regards,
__________________
just an ignorant noob with moronic solution...
Reply With Quote
  #3 (permalink)  
Old 11-01-04, 10:55 PM
4n7hr4x 4n7hr4x is offline
Banned
 
Join Date: Jun 2004
Posts: 237
Thanks: 0
Thanked 0 Times in 0 Posts
you can always do is_numerical($date){ but the above method is better for a more specific checking
Reply With Quote
  #4 (permalink)  
Old 11-06-04, 01:51 AM
jozin jozin is offline
Newbie Coder
 
Join Date: Oct 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks

Hi guys,

Thanks for the info. I wonder why PHP didn't make a built-in function for it(like isDate() in VB).

More power.

jozin
Reply With Quote
  #5 (permalink)  
Old 11-07-04, 02:03 AM
moronovich moronovich is offline
Junior Code Guru
 
Join Date: Oct 2004
Posts: 460
Thanks: 0
Thanked 0 Times in 0 Posts
i feel the internals will reply like this: it's more like user issue rather than php issue. anyway, this suggestion is ok. i'll try to forward it.
regards,
__________________
just an ignorant noob with moronic solution...
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Error Fairnie PHP 8 06-26-04 07:15 AM
Disable form fields to be submitted RickyRod JavaScript 2 05-24-04 10:15 AM
accessing existing ISP email with a PHP webmail script. nlancaster PHP 1 01-07-04 03:28 AM
Help trim code down TheLaughingBandit JavaScript 0 09-02-03 09:50 AM
edit php in Squirrelmail jrcortrightiii PHP 1 07-10-03 02:08 PM


All times are GMT -5. The time now is 04:42 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.