cturner Posted January 17, 2007 Share Posted January 17, 2007 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] Quote Link to comment https://forums.phpfreaks.com/topic/34489-current-date-isnt-displaying/ Share on other sites More sharing options...
HuggieBear Posted January 17, 2007 Share Posted January 17, 2007 There's nothing wrong with this code, it's displaying Wed 17th Jan 2007 for me.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/34489-current-date-isnt-displaying/#findComment-162452 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.