My goal is to calculate and show end date based on my start date by date picker and doprdown to choose number of weeks.
I have Jquery datetimepicker http://xdsoft.net/jqplugins/datetimepicker/ to select start date and dropdown to select number of weeks.
I'm using below codes to get the end date result but its not working:
week_number_id.on('change', function(e) {
var selectvalue = $(this).val();
//Display 'loading' status in the target select list
date_result_id.html('<i class="uk-icon-spinner uk-icon-spin"></i>');
if (selectvalue == '')
{
date_result_id.html(initial_date_result_html);
}
else
{
//Make AJAX request, using the selected value as the GET
$.ajax({
url: 'index.php',
data:'option=com_mycom&task=getmydateHTML&dvalue='+selectvalue,
success: function(output) {
date_result_id.html(output);
updateSelect(date_result_id.val());
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status + ' ' + thrownError);
}
});
}
});
and on php code:
public function getmydateHTML() {
$jinput = JFactory::getApplication()->input;
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$dt = $jinput->get ('dvalue');
$choosendate = $jinput->get ('start_date');
$newdate = strtotime("+". $dt . "week", $choosendate);
echo date('M d, Y', $newdate);
exit; // this will stop Joomla processing, and not output template modules etc.
}
But after calculation result shows date starting from jan 01, 1970, weeks are increasing correctly but the code can not get the start date.