Jump to content

Current date isn't displaying???


cturner

Recommended Posts

Can someone please have a look at my code and tell me why the date is displaying 1 and not the current date? Thanks in advance.

[code=php:0]
$now = time();
        $lastDay = date("t", $now);
$days = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
        $months = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$thisDay = date("l");
        $thisDate = date("j");
        $thisMonth = date("F");
        $thisYear = date("Y");
       
print "<select name=\"selectDay\" id=\"selectDay\">";
foreach($days as $a) {
$selStr = $a == $thisDay ? " selected=\"selected\"" : "";
print "<option value=\"$a\"$selStr>$a</option>";
}
print "</select>";

        print "<select name=\"selectDate\" id=\"selectDate\">";
        for($i=1; $i<=$lastDay; $i++)
        {
            $selStr = $i == $thisDate ? " selected=\"selected\"" : "";
            print "<option value=\"$i\"$selStr>$i</option>";
        }
        print "</select>";

        print "<select name=\"selectMonth\" id=\"selectMonth\">";
        foreach($months as $v)
        {
            $selStr = $v == $thisMonth ? " selected=\"selected\"" : "";
            print "<option value=\"$v\"$selStr>$v</option>";
        }
        print "</select>";

        print "<select name=\"selectYear\" id=\"selectYear\">";
        for($i=$thisYear; $i<$thisYear+30; $i++)
        {
            $selStr = $i == $thisYear ? " selected=\"selected\"" : "";
            print "<option value=\"$i\"$selStr>$i</option>";
        }
        print "</select>";
[/code]
Link to comment
https://forums.phpfreaks.com/topic/34489-current-date-isnt-displaying/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.