🆒
Hello phpeoples!
I need your help if you can.
I need to create drop down menus for each component of a date string, e.g. (month,day,year,hour,etc)
Can i use a combination of range(), mktime() and strtotime()
to create an array of, say all the months. these are non-numeric entries, so I can't just flat out use range, like I can for the other numeric components.
Thanks for your input!
nemesis.
My functions:
/////////////////////////////////////////////////////////////
function menu_options($input,$arr){
if(is_array($arr) ){
foreach($arr as $ar){
//echo $input, " ", $ar, "<br />";
if($input == $ar){
$fld ="<option selected value='".$ar."'>".ucfirst($ar)."</option>";
}else{
$fld ="<option value='".$ar."'>".ucfirst($ar)."</option>";
}
$opt .= $fld;
}
return $opt;
}else{
return NULL;
}
}
////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
function menu_date($date){
$month = date("M",strtotime($date));
$day = date("d",strtotime($date));
$year = date("Y",strtotime($date));
$hour = date("h",strtotime($date));
$min = date("i",strtotime($date));
$sun = date("a",strtotime($date));
dbg($month.$day.$year.$hour.$min.$sun);
//$formatted_date = date("M d Y",strtotime($date));
$formatted_time = date("h:i a",strtotime($date));
$month_arr = menu_options($month,range(1,12,1))
}
/////////////////////////////////////////////////////////////