Anyone got a regular code snippet they use for this?
There's got to be a more elegant way than the following:
Especially considering it doesn't even take into account how many days in the month...
There's got to be a more elegant way than the following:
Code:
$nowDate = date("d");
$nowMonth = date("m");
$nowYear = date("Y");
for ($i = 1; $i <= 9; $i++)
{
if ($nowDate == "0$i")
{
echo "<option value='0$i' selected=\"selected\">0$i</option>\n";
}
else
{
echo "<option value='0$i'>0$i</option>\n";
}
}
for ($i = 10; $i <= 31; $i++)
{
if ($nowDate == $i)
{
echo "<option value='$i' selected=\"selected\">$i</option>\n";
}
else
{
echo "<option value='$i'>$i</option>\n";
}
}
Especially considering it doesn't even take into account how many days in the month...