Working with Dates, help.
Posted on
16th Feb 2014 07:03 pm by
admin
Sooo to make a long story short, here's what im trying to accomplish.
I need to create a dropdown list of months, where the starting month is current month and the ending month is the previous months 2 years earlier.
Example of static version
Code: [Select]<option VALUE="">-Month-</option>
<option VALUE="0" >Oct-2009</option>
<option VALUE="1" >Sep-2009</option>
<option VALUE="2" >Aug-2009</option>
<option VALUE="3" >Jul-2009</option>
<option VALUE="4" >Jun-2009</option>
<option VALUE="5" >May-2009</option>
<option VALUE="6" >Apr-2009</option>
<option VALUE="7" >Mar-2009</option>
<option VALUE="8" >Feb-2009</option>
<option VALUE="9" >Jan-2009</option>
<option VALUE="10" >Dec-2008</option>
<option VALUE="11" >Nov-2008</option>
<option VALUE="12" >Oct-2008</option>
<option VALUE="13" >Sep-2008</option>
<option VALUE="14" >Aug-2008</option>
<option VALUE="15" >Jul-2008</option>
<option VALUE="16" >Jun-2008</option>
<option VALUE="17" >May-2008</option>
<option VALUE="18" >Apr-2008</option>
<option VALUE="19" >Mar-2008</option>
<option VALUE="20" >Feb-2008</option>
<option VALUE="21" >Jan-2008</option>
<option VALUE="22" >Dec-2007</option>
<option VALUE="23" >Nov-2007</option>
<option VALUE="24" >Oct-2007</option>
<option VALUE="25" >Sep-2007</option>
<option VALUE="26" >Aug-2007</option>
<option VALUE="27" >Jul-2007</option>
<option VALUE="28" >Jun-2007</option>
Now it's easy to figure out current month through getDate();
The loop is relatively easy also. But i dont know how to use the date to subtract if you will the months and years from the current date.
So all in all i need to create the code above dynamically.
Thanks Guys
No comments posted yet
Your Answer:
Login to answer
212
26
Other forums
progress bar...need expert opinion of experienced webmaster
Hey guys, quick question:
I want to display a progress bar when I upload files, but I am not
some questions
Hello,
I am looking for the answers for following questions:
1) Does PHP support overl
Update data to upper case in parent/child tables
Hi Gurus!
In production we have a product table and which is being reference by many tabl
Echoing ASCII code
I have a php page that splits a string into chars and then echoes the ASCII code for each char. I'm
Php script to read msword file
hi,
I need to read a msword file and i want to print the contents in that word file.
i
regex for quoted text within a string
I am still getting the hang of regex expressions, but I cant seem to figure out how I would escape q
Must-Know Topics of PHP
Can you guys list the must-know topics of PHP. I am still a learner and I am trying to cover most of
PHP hyperlinks generator
Hi
I need some help to get this done using php:
1 - I have few hyperlinks say 500
Else statement screws up all css
Does anyone know what goes wrong in the process with this php code?
This code seems to be causing
How to create a static html menu from a database
Hi,
I have built a small cms which allows me to create simple html pages and then upload them