Date Calculation In Quarters

Hello Friends.

I have a Problem on Date calculation.

I have 3 Fields, 1. start date. 2. Time period (Dropdown). 3.Maturity date.

Now am created the start date. The problem is in the time period dropdown. The time period is in the Quarters and in the years.

For eg. if the start date is 7/8/2014.

In Dropdown I have 3months 6months 9months 1yr 2 yrs. calculating this 2 fields and this will displayed in the maturity date.

How can I manage this quarters with like onchange().

One more thing is, In future I may add the time period like 3years 4 years. how I manage this calculation.

Help me out!!!

The calculation is a math problem, not a yii problem.

In PHP, the usual way to do so is to first convert your date to unix time, and then to calculate the differences in seconds, and then to convert back your result in date.

Don’t use list dropdown : it’s ultra oldschool, managed directly by the browsers, and you’l have many problems in javascript.

You rather Use button dropdown style :

You can build it by yourself, you can also use bootstrap for yii via yiibooster: