Forums

How can I select a range of dates

cornelio 03 Jul, 2015
Hi, Bob

I would like to replicate this your http://greyhead.org/index.php?option=com_chronoforms&tmpl=component&chronoform=linked_datepickers_b wonderful example of range dates but I can not make it work with CFV5. I tried various posts but are unfortunately not able to understand.

currently I have included a function like this
 var _MS_PER_DAY = 1000 * 60 * 60 * 24;

// a e b sono oggetti Data
function dateDiffInDays(a, b) {
  // Esclude l'ora ed il fuso orario
  var utc1 = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate());
  var utc2 = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate());

  return Math.floor((utc2 - utc1) / _MS_PER_DAY);
}

function getDateDiffInDays() {
 var YA = document.getElementById("YA").value
 var MA = document.getElementById("MA").value
 var DA = document.getElementById("DA").value
 var YB = document.getElementById("YB").value
 var MB = document.getElementById("MB").value
 var DB = document.getElementById("DB").value

 var date1 = new Date(YA + "/" + MA + "/" + DA);
 var date2 = new Date(YB + "/" + MB + "/" + DB);
    
 var el = document.getElementById("date_diff")
 el.innerHTML = dateDiffInDays(date1, date2)    
}

and it works perfectly, but I would use datepicker of CFV5

Thanks in advance

Cornelio
Max_admin 17 Jul, 2015
Hi Cornelio,

For v5 please check this FAQ:
http://www.chronoengine.com/faqs/70-cfv5/5216-date-control-using-cfv5-date-picker-element.html

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.