Hi all,
I've got a v small function that takes a date, checks it and returns the full date
e.g
$me->find_day_name('22','10','2002');
will return
Below is the function as it stands:
class calendar
{
function calendar()
{
}
function find_day_name($day_number,$month_number,$year_number)
{
if(!empty($day_number))
{
if(!empty($month_number))
{
if(!empty($year_number))
{
if(!$date = checkdate($month_number,$day_number,$year_number))
{
$fixed = date('l F j, Y', mktime(0,0,0,$month_number,$day_number,$year_number));
return 'Perhaps you meant '. $fixed.' ';
}else{
return strftime("%A %d %B %Y\n",mktime(0,0,0,$month_number,$day_number,$year_number));
}
}else{
if(!$date = checkdate($month_number,$day_number,date("Y")))
{
$fixed = date('1 F j, Y', mktime(0,0,0,$month_number,$day_number,date("Y")));
return 'Perhaps you meant '. $fixed.' ';
}else{
return strftime("%A %d %B %Y\n",mktime(0,0,0,$month_number,$day_number,date("y")));
}
}
}else{
if(!$date = checkdate(date("m"),$day_number,date("Y")))
{
$fixed = date('l F j, Y', mktime(0,0,0,date("m"),$day_number,date("Y")));
return 'Perhaps you meant '. $fixed.' ';
}else{
return strftime("%A %d %B %Y\n",mktime(0,0,0,date("m"),$day_number,date("y")));
}
}
}else{
if(!$date = checkdate(date("m"),date("d"),date("Y")))
{
$fixed = date('l F j, Y', mktime(0,0,0,date("m"),date("d"),date("Y")));
return 'Perhaps you meant '. $fixed.' ';
}else{
return strftime("%A %d %B %Y\n",mktime(0,0,0,date("m"),date("d"),date("Y")));
}
}
}
}
$me = new calendar;
print $me->find_day_name('22','10','2002');
Now note that nowhere is there
$this->
so it is not really a method. The code above works fine, however as soon as i put
$this->????
(e.g $this->month_name) it stops working it simply returns todays date. I want to be able to create this function into a method so that i can use it again and again.
Anyone got any ideas why this is not working when i put
$this->
Cheers
GM