Hi all,
I am creating a form that need the months difference between today and a date picked from the Mootools Datepicker calendar.
How can i do this?
Many thanks to all.
Renas
I am creating a form that need the months difference between today and a date picked from the Mootools Datepicker calendar.
How can i do this?
Many thanks to all.
Renas
Hi renas,
Do you need this calculated in the browser using JavaScript so that it can be displayed in the form; or is it enough to do it with PHP after the form is submitted?
How exactly do you define the calculation you need? What happens about part months?
Bob
Do you need this calculated in the browser using JavaScript so that it can be displayed in the form; or is it enough to do it with PHP after the form is submitted?
How exactly do you define the calculation you need? What happens about part months?
Bob
Hi GreyHead,
After some long read i have found a solution.
I am working the values onchange on the form. So, Javascript and Mootools Datepicker. I am using Joomla 2.5
For the solution i have made this:
1. On advanced edit of form, DateTime Picker config. This will guarantee that value is recalculated if date changes.
2. In the "Load JS" action
- For the local code of calendar. This will give me Months and Week days in my language. If supported in the Mootools DatePicker. In my case is supported.
- For the months difference
The purpose of this code is to calculate loans.
Hope will help someone else,🙂
Tks,
Renas
After some long read i have found a solution.
I am working the values onchange on the form. So, Javascript and Mootools Datepicker. I am using Joomla 2.5
For the solution i have made this:
1. On advanced edit of form, DateTime Picker config. This will guarantee that value is recalculated if date changes.
onSelect: myfunction
2. In the "Load JS" action
- For the local code of calendar. This will give me Months and Week days in my language. If supported in the Mootools DatePicker. In my case is supported.
<?php
$lang =& JFactory::getLanguage();
$tag = $lang->getTag();
echo "Locale.use('{$tag}');";
?>
- For the months difference
function myfunction(){
start = $('calendar_box_id').value.split(' ')[0]; //Date Selected
start = new Date().parse(start); //Parse Date
today = new Date(); //Get Today Date
months = start.diff(today, 'month'); //Months difference from today to selected date
};
The purpose of this code is to calculate loans.
Hope will help someone else,🙂
Tks,
Renas
Hi all,
Can anyone give me a help defining the parser of mootools date.
Hi have this date format:
format: '%d-%m-%Y'
Tks,
Renas
Can anyone give me a help defining the parser of mootools date.
Hi have this date format:
format: '%d-%m-%Y'
Tks,
Renas
Hi all,
Have tried this to extract the date.
Both fail, anyone with the same problem?
Tks,
Renas
Have tried this to extract the date.
start = $('data_aquisicao').value.split('-')[0];
start = $('data_aquisicao').get('date');
Both fail, anyone with the same problem?
Tks,
Renas
Hi Renas,
Please look at the earlier example and work out what each line is doing.
Also notice that you seem to have invented some JavaScript which does not match the earlier example.
Bob
Please look at the earlier example and work out what each line is doing.
Also notice that you seem to have invented some JavaScript which does not match the earlier example.
Bob
Hi GreyHead,
The problem is that i need to add months and years to the previous date.
I am using the 'increment' wich seems to get me always bad results.
For this piece of code i need to add months to initial date from the datepicker twice. To determine the end loan date and actual date.
Tks,
Renas
The problem is that i need to add months and years to the previous date.
I am using the 'increment' wich seems to get me always bad results.
loan_date.increment('month',$('integer_value').value);
For this piece of code i need to add months to initial date from the datepicker twice. To determine the end loan date and actual date.
Tks,
Renas
Hi Renas,
I think that increment() will only work if loan_date is a JavaScript date object. Is it? Looking at your earlier code it seems unlikely.
Bob
I think that increment() will only work if loan_date is a JavaScript date object. Is it? Looking at your earlier code it seems unlikely.
Bob
Hi GreyHead,
I detected the problem. The increment works properly. But 'diff' don't.
It seems that Mootools diff accounts 30 days for each month. So, in 50 years this is a big difference when looking at months.
I have replaced by a custom function witch does the work perfectly.
Tks,
Renas
I detected the problem. The increment works properly. But 'diff' don't.
It seems that Mootools diff accounts 30 days for each month. So, in 50 years this is a big difference when looking at months.
I have replaced by a custom function witch does the work perfectly.
Tks,
Renas
This topic is locked and no more replies can be posted.