Jump to content

PHP Date help


steviez

Recommended Posts

Hi,

 

I am making a form to track users earning for the current year and need it to display the months gone all the way up to the current month then auto add each month after that

 

I have searched all over google but cant seem to find any help, anyone got any ideas?

 

Thanks

Link to comment
Share on other sites

Do you mean the rest of the months in this year starting with the current month, or do you mean all of the months up to the current month?

 

I need it to display all the months that have gone up to the current month, then as we move on a month it adds that too

Link to comment
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>";

Link to comment
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.