I just made something very similar to this, so maybe you can use it. It works with jQuery, but in the end I figured it was better than reinventing the wheel.
If you are indeed a kiwi, you will want the date in dd/mm/yy format, which is what this has. If you're not, then I leave it to you to fix as punishment for impersonating one
Code:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
</head>
<body>
<p>Date: <input type="text" id="start" /> <input type="text" id="fin" size="30" /></p>
<div id="res"></div>
<script>
$(function() {
function getDiff() {
var from = $("#start").val();
var till = $("#fin").val();
var c = from.split("/");
beg = new Date(c[2],c[1] - 1,c[0]);
var d = till.split("/");
en = new Date(d[2],d[1] - 1,d[0]);
var rest = (en - beg)/86400000;
var txt=rest==0?"":rest+" days"
$("#res").text(txt);
}
$("#start").datepicker({
changeMonth:true,
changeYear:true,
showAnim:"fadeIn",
gotoCurrent:true,
minDate:0, //change this to +3 to start 3 days from now
dateFormat: "dd/mm/yy",
onSelect: function(dateText, inst) {
$( "#fin" ).val(dateText);
$( "#fin" ).datepicker( "option", "minDate", dateText);
getDiff();
}
});
$("#fin").datepicker({
dateFormat: "dd/mm/yy",
changeMonth:true,
changeYear:true,
showAnim:"fadeIn",
onSelect: getDiff
});
});
</script>
</body>
</html>