get date from float number in php or jquery

Viewed 2282

I am working on a project in which i have to Generate a Date from Selected Option value.

Example:

  1. If selected 1.5 then need a date after 1 Month 15 days 15-08-2017
  2. If selected 1.0 then need a date after 1 Month 17-08-2017

    <select class="form-control" name="days" id="days" required>
        <option data-days="1.5" value="3">After 1 month 15 days</option>
        <option data-days="2.5" value="4">After 2 month 15 days</option>
        <option data-days="6.0" value="10">After 5 month</option>
        <option data-days="7.5" value="30">After 7 month 15 days</option>       
        //And So on...
    </select>
    
    // Here is the script for getting selected option days attribute.
    $('body').on('change', '#days', function(e) {
        var days = $(this).find(':selected').data('days');
    
        // Now How do i get the date according the days. as shown in example
    
    });
    

I have also tried to get the date in PHP but i didn't get it.

$date = date('Y-m-d', strtotime('+1.0 month'));

So can anyone help me to get date using this float numbers in PHP or Jquery.

2 Answers
Related