MyBB Community Forums

Full Version: Admin Panel Dates
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
	function generate_date_select($name, $date, $options)
	{
		
	}

I'm trying to implement a date select and I found this function but there's nothing in it. I was wondering if there is another way of doing this, or will I have to do 3 drop down selects?
Weird, dunno why it's in there if it's empty... it has code in it in the 1.6 version so it looks like you'll need to have three for now, but you'll be able to use the function in 1.6. Or here's the 1.6 version of it, you can just use this as is:

function generate_date_select($name, $day="",$month="",$year="")
{
	global $lang;
	
	$months = array(
		1 => $lang->january,
		2 => $lang->february,
		3 => $lang->march,
		4 => $lang->april,
		5 => $lang->may,
		6 => $lang->june,
		7 => $lang->july,
		8 => $lang->august,
		9 => $lang->september,
		10 => $lang->october,
		11 => $lang->november,
		12 => $lang->december,
	);
	
	// Construct option list for days
	$days = array();
	for($i = 1; $i <= 31; ++$i)
	{
		$days[$i] = $i;
	}
	
	if(!$day)
	{
		$day = date("j", TIME_NOW);
	}
	
	if(!$month)
	{
		$month = date("n", TIME_NOW);
	}
	
	if(!$year)
	{
		$year = date("Y", TIME_NOW);
	}
	
	$built = $this->generate_select_box($name.'_day', $days, intval($day), array('id' => $name.'_day'))." &nbsp; ";
	$built .= $this->generate_select_box($name.'_month', $months, intval($month), array('id' => $name.'_month'))." &nbsp; ";
	$built .= $this->generate_text_box($name.'_year', intval($year), array('id' => $name.'_year', 'style' => 'width: 100px;'));
	return $built;
}
Thanks for that Smile