Re: string->integer
| From: | Chris Lee | Date: | Fri, 23 Mar 2001 13:43:42 +0000 |
| Subject: | Re: string->integer | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-45296@lists.php.net to get a copy of this message | ||
even better, verify the date as a whole rather then just as an int.
<?php
$time = mktime(0, 0, 0, $month, $day, $year);
$date = getdate($time);
$month = $date['mon'];
$day = $date['mday'];
$year = $date['year'];
?>
there you go, try it. someone puts an invalid date in? no problem it fixes it for you.
--
Chris Lee
lee@mediawaveonline.com
""Matt Williams"" <matt@yewlands.com> wrote in message news:BKEBLPOMMAKCLHIBKBOEGEDDCOAA.matt@yewlands.com...
Hi
I am trying to validate a form to check the user has entered there date of
birth correctly
There are three fields day, month & year.
how can I check whether a string is a number?
I have tried using is_long(), is_int(), is_integer() to check the values
,but it doesn't seem to be working.
the code I have tried is
if(!is_int($dobd))
{
print "error";
}
else
{
//carry on
}
could someone help me as to where I'm going wrong
TIA
M@
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net