Page 1 of 1

Posted: Thu Mar 22, 2007 7:29 pm
by Locky
guys this is exactly what i need but the thing doesnt work? if it is just me being retarded can u please show a example how to use it, thank you

Posted: Thu Mar 22, 2007 7:33 pm
by feyd
Which one are you trying to use and what results are you getting? (Note, this thread has not been posted to in over three years.)

Posted: Thu Mar 22, 2007 8:14 pm
by Locky
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


this 1

Code: Select all

function MyCheckDate( $postedDate ) {
   if ( preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $postedDate) ) {
      list($year , $month , $day) = explode('-',$postedDate);
      return checkdate($month , $day , $year);
   } else {
      return false;
   }
}
and for calling iut useing
MyCheckDate($test);

$test = "1989-12-12"


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Mar 22, 2007 9:25 pm
by Kieran Huggins
use the other function instead...

Code: Select all

function MyCheckDate( $postedDate ) {
   if (preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $postedDate, $datebit)) {
      return checkdate($datebit[2] , $datebit[3] , $datebit[1]);
   } else {
      return false;
   }
}

Posted: Thu Mar 22, 2007 9:52 pm
by Locky
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


this is correct yes ?

Code: Select all

<?
$test = '12-12-2008';
MyCheckDate( $test );
function MyCheckDate( $postedDate ) {
   if (preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $postedDate, $datebit)) {
      return checkdate($datebit[2] , $datebit[3] , $datebit[1]);
   } else {
      return false;
   }
}
?>
not doin anythin i must be doin sumthin wrong


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Mar 22, 2007 10:21 pm
by Kieran Huggins
your date: 31-12-2008 is not in the same form you're expecting: 2008-12-31

Posted: Thu Mar 22, 2007 10:41 pm
by Locky
i changed the date but still the script does nothing at all

Posted: Thu Mar 22, 2007 10:44 pm
by feyd
It doesn't print anything, if that's what you're looking for. You must examine the return value from it to find out whether it passed or failed.

Posted: Thu Mar 22, 2007 10:46 pm
by Locky
i cant look at the return value as the script does nothing at all, does it work for you's ?

Posted: Thu Mar 22, 2007 11:04 pm
by feyd
How do you know it does nothing?

Posted: Thu Mar 22, 2007 11:05 pm
by Locky
cant see anything just a blank page and nothing in the source

Posted: Thu Mar 22, 2007 11:21 pm
by feyd
Note that I said something about that previously...
feyd wrote:It doesn't print anything, if that's what you're looking for.
You need to add some code to do the comparison.

Posted: Fri Mar 23, 2007 12:37 am
by dude81

Code: Select all

<? 
$test = '2008-12-12'; 
MyCheckDate( $test ); 
function MyCheckDate( $postedDate ) { 
   if (preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $postedDate, $datebit)) { 
         print_r($datebit);
      return checkdate($datebit[2] , $datebit[3] , $datebit[1]); 
   } else { 
      return false; 
   } 
} 
?>
The above code showed me it works perfectly for the above $test type of date. still what doesn't work??

Posted: Fri Mar 23, 2007 4:56 am
by Locky
ahhh thank you ! i didnt realise had to do that thakns a lot, sorry i was bein so stupid :P