I have the following script which produces a selection box with various dates, ie....
1-11-2005
2-11-2005
3-11-2005
I want to store a specified date in mysql, stripping the hash and changing it to mysql date so that I can do date functions, ie. days between dates.
Any ideas? Here is my script;
Code: Select all
<?
$leap = array(1, 0, 0, 0, 1, 0); //<- Not accurate! Look up the leapyears.
$years = array(2005, 2006, 2007); //<- List of years
echo "<SELECT NAME=Date><OPTION>Choose One</OPTION>n";
foreach ($years as $year) { //Cycle thru years
for ($i = 1; $i<=12; $i++) { //Cycle thru months
$day = 1; //Start at day 1
while ($day <= date('t', $month = mktime(0, 0, 0, $i, 1, $year))) { //Cycle thru days
echo "<OPTION VALUE={$day}, "
.date('m', $month)
.", {$year}>{$day} "
.date('m', $month)."-{$year}</OPTION>\n";
$day++;
}
}
}
echo "</SELECT>\n";
?>