Can I remove Year from this code ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ClassicNancy
    New Member
    • Jun 2007
    • 8

    #1

    Can I remove Year from this code ?

    If I want to remove the drop down for the year will that make the birthday not show on the calendar? If it looks like it is ok to remove it what can be removed?? What should it look like?


    [PHP]function date_selection( $default_date=" ", $field_names=ar ray("user_birth day_month", "user_birthday_ day", "user_birthday_ year"), $labels=1)
    // Returns date selection as a drop-down menu, if field names are omitted birthday fields are used
    {
    // Determine start date
    if ($default_date)
    {
    if (strpos($defaul t_date, "-"))
    {
    list($year, $month, $day) = explode("-", $default_date);
    if (substr($year, 0, 1) == "s")
    {
    $year = substr($year, 1);
    $start_date = ($year > date("Y")) ? date("Y") : $year;
    }
    }
    else if (substr($defaul t_date, 0, 1) == "s")
    $start_date = substr($default _date, 1, 4);
    }

    if (!$start_date)
    $start_date = 1900;

    $months = array(
    lg("month_janua ry"),
    lg("month_febru ary"),
    lg("month_march "),
    lg("month_april "),
    lg("month_may") ,
    lg("month_june" ),
    lg("month_july" ),
    lg("month_augus t"),
    lg("month_septe mber"),
    lg("month_octob er"),
    lg("month_novem ber"),
    lg("month_decem ber"));

    if ($labels)
    {
    $month_list = sprintf('<OPTIO N VALUE="00">%s</OPTION>%s', lg("month"), "\n");
    $day_list = sprintf('<OPTIO N VALUE="00">%s</OPTION>%s', lg("day"), "\n");
    $year_list = sprintf('<OPTIO N VALUE="0000">%s </OPTION>%s', lg("year"), "\n");
    }

    for ($i = 0; $i < 12; $i++)
    {
    ($i == $month - 1) ? $is_selected = " SELECTED" : $is_selected = "";
    $month_list .= sprintf(' <OPTION VALUE="%s"%s>%s </OPTION>%s', $i + 1, $is_selected, $months[$i], "\n");
    }

    for ($i = 1; $i <= 31; $i++)
    {
    ($day == $i) ? $is_selected = " SELECTED" : $is_selected = "";
    $day_list .= sprintf(' <OPTION VALUE="%02d"%s> %02d</OPTION>%s', $i, $is_selected, $i, "\n");
    }

    (($field_names[0] == "user_birthday_ month") or (strlen($defaul t_date) <= 5)) ?
    $current_year = date("Y") : $current_year = 2037;

    for ($i = $start_date; $i <= $current_year; $i++)
    {
    ($year == $i) ? $is_selected = " SELECTED" : $is_selected = "";
    $year_list .= sprintf(' <OPTION VALUE="%s"%s>%s </OPTION>%s', $i, $is_selected, $i, "\n");
    }

    // Sort fields according to date format
    $parts = preg_split('/\-|\s+|,/', USER_DATE_FORMA T);
    foreach ($parts as $part)
    if (in_array($part , array("m", "M", "F")))
    $sorted_output[] = array($field_na mes[0], $month_list);

    else if (in_array($part , array("d", "j", "jS")))
    $sorted_output[] = array($field_na mes[1], $day_list);

    else if ($part == "Y")
    $sorted_output[] = array($field_na mes[2], $year_list);

    $date_field1 = (strpos($sorted _output[0][0], '"') !== false) ? $sorted_output[0][0] : '"' . $sorted_output[0][0] . '"';
    $date_field2 = (strpos($sorted _output[1][0], '"') !== false) ? $sorted_output[1][0] : '"' . $sorted_output[1][0] . '"';
    $date_field3 = (strpos($sorted _output[2][0], '"') !== false) ? $sorted_output[2][0] : '"' . $sorted_output[2][0] . '"';

    return sprintf('<SELEC T NAME=%s ID="wgui_%s">%s </SELECT>' . "\n" .
    '<SELECT NAME=%s ID="wgui_%s">%s </SELECT>' . "\n" .
    '<SELECT NAME=%s ID="wgui_%s">%s </SELECT>' . "\n",
    $date_field1, str_replace('"' , '', $date_field1), $sorted_output[0][1],
    $date_field2, str_replace('"' , '', $date_field2), $sorted_output[1][1],
    $date_field3, str_replace('"' , '', $date_field3), $sorted_output[2][1]);
    }[/PHP]
Working...