Today we can Learn How to Create Reusable Date picker Using Php Programming Language.Its reusable php function for datepicker.Just Apply the function and get the datepicker.
Just follow this step for creating a Datepicke:
Then we’ll construct the three dropdowns like month ,day,year :
For Month :
For Day :
For Year :
Final code for datepickr :
The result that will come in $_POST after submitting such form $_POST['registrationmonth'], $_POST['registrationday'] and $_POST['registrationyear'].
Display Preview:

Just follow this step for creating a Datepicke:
Then we’ll construct the three dropdowns like month ,day,year :
For Month :
$html="<select name=\"".$name."month\">";
 for($i=1;$i<=12;$i++)
 {
    $html.="<option value='$i'>$months[$i]</option>";
 }
$html.="</select> "; 
For Day :
$html.="<select name=\"".$name."day\">";
 for($i=1;$i<=31;$i++)
 {
    $html.="<option value='$i'>$i</option>";
 }
 $html.="</select> ";
For Year :
$startyear = date("Y")-100;
$endyear= date("Y")+50;
 $html.="<select name=\"".$name."year\">";
 for($i=$startyear;$i<=$endyear;$i++)
 {
   $chooser.="<option value='$i'>$i</option>";
 }
 $html.="</select> ";
Final code for datepickr :
function date_picker($name, $startyear=NULL, $endyear=NULL)
{
if($startyear==NULL) $startyear = date("Y")-100;
if($endyear==NULL) $endyear=date("Y")+50;
$months=array('','January','February','March','April','May',
'June','July','August', 'September','October','November','December');
// Month dropdown
$html="<select name=\"".$name."month\">";
for($i=1;$i<=12;$i++)
{
$html.="<option value='$i'>$months[$i]</option>";
}
$html.="</select> ";
// Day dropdown
$html.="<select name=\"".$name."day\">";
for($i=1;$i<=31;$i++)
{
$html.="<option $selected value='$i'>$i</option>";
}
$html.="</select> ";
// Year dropdown
$html.="<select name=\"".$name."year\">";
for($i=$startyear;$i<=$endyear;$i++)
{
$html.="<option value='$i'>$i</option>";
}
$html.="</select> ";
return $html;
}
echo date_picker("registration"); 
use the function as echo date_picker(“registration”) (for example – “registration” is just a name you choose).The result that will come in $_POST after submitting such form $_POST['registrationmonth'], $_POST['registrationday'] and $_POST['registrationyear'].
Display Preview:

Hi,
ReplyDeleteRecently I came across some great articles on your site.
The other day, I was discussing (http://phpwebprogramminglearningtutorialcode.blogspot.in/2012/11/datepicker-using-php-script-language.html)with my colleagues and they suggested I submit an article of my own. Your site is just perfect for what I have written!
Would it be ok to submit the article? It is free of charge, of course!
Let me know what you think
Contact me at anelieivanova@gmail.com
Regards
Anele Ivanova