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.

Did you know?Explore Trending and Topic pages for more stories like this.
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 Like 26 Dislike
Previous forums Next forums
Other forums

php not working written for consumption of slots
1. Here is the function where i will be allowed to consume the slot booked by me.

2. Here i c

PL/SQL: ORA-00947: not enough values error message
Hi all i am getting Error(25,63): PL/SQL: ORA-00947: not enough values error message when executing

Strange php code found on my website
I got hacked and the following code was placed within my files:

Code: [Select]<?
/*

Change Web page language
i doing this thing first time but i dont find any suitable solution for it. On the demand of user. I

Linkage between two scripts
Okay say I have this for a link in a script:

Code: <li><a href="#&q

check how many commas the variable containing the query has between [i]select[/i
Hi...

iv made an sql table that contains id number - name of sql query and an sql query.
T

PHP4 to PHP5 Conversion
Hi Everyone,

I am working on a site that is built up on PHP4 and each page is being started f

Not sure why this script is not working?
Hi I am new to php programing and I was trying to make up a simple script like a captcha but I canno

MySQL issue
I am taking sentences through a form on page. Then checking some condition and trying to insert them

drop-down with sub-category appear
Hello,

i know how to build a simple dro-down list, im looking for a code when im gonna choose

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash