Date calculation

bertbastiaan

New Member
Hi,

I have a date field called:
boekingen___aankomst

I created another field called:
boekingen___uiterste

I like to display here :
boekingen___aankomst minus 30 days

So in "Renders standard Joomla Date Picker"options, I created this:
return '{boekingen___aankomst - 30 days}';

Now I get this error:
0 DateTime::__construct(): Failed to parse time string ({boekingen___aankomst - 30 days}) at position 0 ({): Unexpected character

What did I do wrong?
 
No, that won't work.

Do you need the date calculation to be done on the page in the browser? So if someone changes the date in the first element, the second element updates ?

-- hugh
 
You'd need some custom JS. Try adding a "change" JS event on the date element you are basing the change on (aankomst), with the following code:

Code:
var myDate = new Date(this.getValue());
myDate.setTime(myDate.getTime() - (60*60*24*1000*30));
this.form.formElements.get('boekingen___uiterste').update(myDate.format('%Y-%m-%d %H:%M:%S'));

The (60*60*24*1000*30) calculates milliseconds in 30 days, as the getTime() and setTime() functions use milliseconds.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top