473,463 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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=array("user_birthday_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($default_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($default_date, 0, 1) == "s")
$start_date = substr($default_date, 1, 4);
}

if (!$start_date)
$start_date = 1900;

$months = array(
lg("month_january"),
lg("month_february"),
lg("month_march"),
lg("month_april"),
lg("month_may"),
lg("month_june"),
lg("month_july"),
lg("month_august"),
lg("month_september"),
lg("month_october"),
lg("month_november"),
lg("month_december"));

if ($labels)
{
$month_list = sprintf('<OPTION VALUE="00">%s</OPTION>%s', lg("month"), "\n");
$day_list = sprintf('<OPTION VALUE="00">%s</OPTION>%s', lg("day"), "\n");
$year_list = sprintf('<OPTION 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($default_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_FORMAT);
foreach ($parts as $part)
if (in_array($part, array("m", "M", "F")))
$sorted_output[] = array($field_names[0], $month_list);

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

else if ($part == "Y")
$sorted_output[] = array($field_names[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('<SELECT 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]
Jun 8 '07 #1
0 1166

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Protoman | last post by:
Hi!!! I need some help on a project I'm that calculates leap years; I'm getting errors that I have no idea what they mean; here's the code: #include <iostream> #include <cstdlib> using...
9
by: mistral | last post by:
Need help to remove list of days from date script. Need format "June 07, 2006" <SCRIPT LANGUAGE="JavaScript"> <!-- Begin // Get today's current date. var now = new Date();
4
by: Chuy08 | last post by:
If I have a multdimensional array like so: $records = array( array('product' ='30 year','rate'=6.0 'ProgramID' =>9514), array('product' ='30 year','rate'=6.0 'ProgramID' =>9514),...
33
by: llothar | last post by:
I'm afraid that the GIL is killing the usefullness of python for some types of applications now where 4,8 oder 64 threads on a chip are here or comming soon. What is the status about that for...
1
by: digidave | last post by:
I am keenly aware that my coding skills are extremely noob but please indulge me a second.. Take a look at these queries.. $sql = "SELECT DISTINCT year FROM _current_floats_config WHERE active =...
5
by: jimix | last post by:
here's what i have. using microsoft studio #define _CRT_SECURE_NO_DEPRECATE #include <stdio.h> int main( void ) { int year, b, c, e; b = 4; c = 100;
3
by: yogi_bear_79 | last post by:
I have a char *year that contains a 4-digit year (i.e 1929), I use the following syntax c = atoi(year); to convert it to an integer. However I must strip the first two numbers. I've tried to...
10
by: sparks | last post by:
We are entering mm/dd/yyyy but some of the date fields only contain years. Can a date be made to only take a year entry if that is all that they have? can it be made to take only 2008 or maybe...
4
by: hallsers | last post by:
Here is the problem i am having: - When a user logs in, on page load it will take the dob of all users in a stored friends list and compare them against the following conditions - To display any...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.