Putting current date in <option selected>

What is the best way to get the current year month & day into a dropdown box? I am doing this->

[php]<?php echo date('Y'); ?>[/php]

and so on for the month and day. It works fine if i just put text in place of the php code, but it is displaying nothing but a blank dropdown box. any suggestions?

Hey,

Sounds like the php code is not processed. Are you sure you saved your file with .php extension?

Regards,
developer.dex2908

yes, it is saved as php. i save all my pages as php, not sure if thats a bad or good thing…

you shouldn’t need to store it in a variable but you might as well try it…

also do you have tags around
[php]

<?php $date = date("Y"); ?> <?php echo $date; ?> [/php]

If you want day and month as well as the year

d = day (2 digit)
m = month (2 digit)
Y = year (4 digit)

[php]$date = date(“m/d/Y”);
echo $date;[/php]
returns “09/28/1012”

[php]$date = date(“Y/m/d”);
echo $date[/php]
returns “2012/09/28”

Are you still having problems with this?

whoops thought i hit topic solved on this one.

Sponsor our Newsletter | Privacy Policy | Terms of Service