PHPBuilder - Check dates interval function

RSS Twitter

Check dates interval function

by: Daniel
October 1, 2002

Version: 1.0

Type: Function

Category: Calendars/Dates

License: GNU General Public License

Description: Check dates interval from two edit boxes inputed in form dd-mm-yyyy (instead of - sperator u can use . or /)

function okdata($date1,$date2)
// split date into day,month,year vars with separators / or . or -. U can add more seps
	$splited1=split ('[/.-]', $date1);
	$splited2=split ('[/.-]', $date2);



//extract last day from given month



//validate last day from given month
	if ($day1>$lastday1)
	$outerr.="Invalid day of month for first field!";

	if ($day2>$lastday2)
	$outerr.="Invalid day of month for second field!";

	$mktime1=mktime (0,0,0,$month1,$day1,$year1);
	$mktime2=mktime (0,0,0,$month2,$day2,$year2);

//calculate difference between dates

	if ($diff<0)

	$outerr.="First date cannot be greater than second date!<br>";

	if ($diff==0)

	$outerr.="Second date cannot be equal with first date!<br>";

	if ($error==-1)
	return $outerr;
	return "Date interval succesfully validated!";


Comment and Contribute

Your comment has been submitted and is pending approval.




(Maximum characters: 1200). You have characters left.