Jump to content

PHP Date help


steviez

Recommended Posts

See if this will work for you:

 

print "<select name='QuoteMonth'>".implode("\n",array_map(create_function('$n','return"<option value=\"$n\"".(date("n")==$n?"selected=\"selected\"":"").">".strftime("%b",strtotime("2004-$n-01"))."</option>";'),range(1,date('m'))))."</select>";

Link to comment
https://forums.phpfreaks.com/topic/200619-php-date-help/#findComment-1052792
Share on other sites

See if this will work for you:

 

print "<select name='QuoteMonth'>".implode("\n",array_map(create_function('$n','return"<option value=\"$n\"".(date("n")==$n?"selected=\"selected\"":"").">".strftime("%b",strtotime("2004-$n-01"))."</option>";'),range(1,date('m'))))."</select>";

 

hi,

 

thanks for your help. That seems to work as i need it but how would i get this to work in a html table to display data for each month?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/200619-php-date-help/#findComment-1052795
Share on other sites

Would this work?

 

print "<select name=\"month\">"."\n".implode("\n",array_map(create_function('$n','return"  <option value=\"".strftime("%b",strtotime("2004-$n-01"))."\"".(date("n")==$n?" selected=\"selected\"":"").">".strftime("%b",strtotime("2004-$n-01"))."</option>";'),range(1,date('m'))))."\n"."</select>";

Link to comment
https://forums.phpfreaks.com/topic/200619-php-date-help/#findComment-1052828
Share on other sites

Would this work?

 

print "<select name=\"month\">"."\n".implode("\n",array_map(create_function('$n','return"  <option value=\"".strftime("%b",strtotime("2004-$n-01"))."\"".(date("n")==$n?" selected=\"selected\"":"").">".strftime("%b",strtotime("2004-$n-01"))."</option>";'),range(1,date('m'))))."\n"."</select>";

 

 

thats the same code as above

Link to comment
https://forums.phpfreaks.com/topic/200619-php-date-help/#findComment-1052917
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.