|
|
|
| Title : |
Creates three SELECT form fields: Month, Day, and Year. You give it a string which will be used to make the name for the three fields, and a number of seconds to use as the default date. If you give it blank for this value, the current date is used. |
| Categories : |
HTML and PHP, PHP, Date Time |
 Leon Atkinson |
| Date : |
Jan 17th 1999 |
| Grade : |
2 of 5 (graded 3 times) |
| Viewed : |
25855 |
| File : |
No file for this code example. |
| Images : |
No Images for this code example. |
|
| Search : |
More code by Leon Atkinson |
|
| Action : |
Grade This Code Example
|
|
| Tools : |
My Examples List |
|
|
|
|
|
|
<?php
/****************************************/
/*Function:DateSelector v1.1 */
/*Code: PHP 3 */
/*Author: Leon Atkinson <leon@clearink.com> */
/*Creates three form fields for get month/day/year */
/*Input: Prefix to name of field, default date */
/*Output: HTML to define three date fields */
/****************************************/
function DateSelector($inName, $useDate=0)
{
/* create array so we can name months */
$monthName = array(1=> "January", "February", "March",
"April", "May", "June", "July", "August",
"September", "October", "November", "December");
/* if date invalid or not supplied, use current time */
if($useDate == 0)
{
$useDate = Time();
}
/* make month selector */
echo "<SELECT NAME=" . $inName . "Month>\n";
for($currentMonth = 1; $currentMonth <= 12; $currentMonth++)
{
echo "<OPTION VALUE=\"";
echo intval($currentMonth);
echo "\"";
if(intval(date( "m", $useDate))==$currentMonth)
{
echo " SELECTED";
}
echo ">" . $monthName[$currentMonth] . "\n";
}
echo "</SELECT>";
/* make day selector */
echo "<SELECT NAME=" . $inName . "Day>\n";
for($currentDay=1; $currentDay <= 31; $currentDay++)
{
echo "<OPTION VALUE=\"$currentDay\"";
if(intval(date( "d", $useDate))==$currentDay)
{
echo " SELECTED";
}
echo ">$currentDay\n";
}
echo "</SELECT>";
/* make year selector */
echo "<SELECT NAME=" . $inName . "Year>\n";
$startYear = date( "Y", $useDate);
for($currentYear = $startYear - 5; $currentYear <= $startYear+5;$currentYear++)
{
echo "<OPTION VALUE=\"$currentYear\"";
if(date( "Y", $useDate)==$currentYear)
{
echo " SELECTED";
}
echo ">$currentYear\n";
}
echo "</SELECT>";
}
?>
<HTML>
<BODY>
<FORM>
Choose a Date: <?php DateSelector( "Sample"); ?>
</FORM>
</BODY>
</HTML> |
|
| Customizable Calendar Class Categories : HTML and PHP, Date Time, PHP, PHP Classes, Calendar | | | PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use! Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP | | | Website colour changer Categories : PHP, HTML and PHP, Date Time | | | This script contains 2 functions: 1 to create html select object based on your own customer date format entry- "M d Y h:i.... etc". The second function processes the select object on submit back to unix time. Categories : PHP, Calendar, Date Time, HTML and PHP | | | Select with current month Categories : PHP, HTML and PHP, Date Time, Arrays | | | Calendar using Date function Categories : HTML and PHP, PHP, Date Time, Calendar | | | CALENDAR - easy calendar-navigation with PHP Categories : PHP, Date Time, HTML and PHP, Calendar | | | Local-to-user date and time display regardless of time zone or where the website's server is located Categories : PHP, Date Time, HTML and PHP, Java Script | | | Simple PHP control CSS Calendar Categories : PHP, HTML and PHP, Calendar, Date Time, CSS | | | Convert date's in YYYY-MM-DD (i.e. mysql format) into PHP3 timestamps. Also Find the difference in days between two PHP3 timestamps. Categories : HTML and PHP, PHP, MySQL, Date Time | | | If you want to create select buttons featuring current date this example will show you how... Categories : Date Time, HTML and PHP, PHP | | | Kewl Date Example Categories : PHP, HTML and PHP, Date Time, CSS, Beginner Guides | | | TreeView - Finally a working tree view function to be used as you want. Simple create the Table using the code provided and you will be able to have a tree view in your project. Download the zip to get the images. Categories : PHP, HTML and PHP, Navigation | | | Using PHP im HTML image tags Categories : PHP, HTML and PHP, Graphics, Beginner Guides | | | How to preset a text string in a textarea input field Categories : HTML, HTML and PHP, PHP, Beginner Guides | |
|
|