Q:

jQuery: how do I convert input content to date object? 

I am writing an application that contains a datepicker.  When you click on a date in the datepicker, the date shows up in an input-field (type="text").  For example, if you choose tomorrow's day it shows:   
09.02.2014  
So as you can guess the format is dd/mm/yyyy.  
For the application I need to calculate the number of days between the date picked and the current date.  I already know how to generate the current date with jQuery.  But I have no clue how to calculate the time difference in days.  Anyone maybe can help out with a code?  

A:

H i , A traditional method would look something like this. 
Starting with the date value in the dot notation format we can convert to the dd/mm/yyyy format. 
UPDATE as comment, given that the date string needs reordering into MM/DD/YYYY
 var inputval = "09.02.2014".split("."); 
 var dateval = new Date(inputval[1]+"/"+inputval[0]+"/"+inputval[2]);

 /* with our Date object we can now compare */
 var currDate = new Date();
 var diffDays = Math.round(Math.abs((dateval.getTime() - currDate.getTime())/(24*60*60*1000)));

The var diffdays = quick date compare snippet taken from :
How to calculate the number of days between two dates using JavaScript? 
Worth to mention about adding all this into a function for re-usability. 
function daysDifferenceFromToday(datestr) {
 var inputval = datestr.split("."); 
 var dateval = new Date(inputval[1]+"/"+inputval[0]+"/"+inputval[2]);
 var currDate = new Date();
 return Math.round(Math.abs((dateval.getTime() - currDate.getTime())/(24*60*60*1000)));

}

/* usages */
alert(daysDifferenceFromToday("09.02.2014"));

if(daysDifferenceFromToday("05.02.2014")>2) {
  ... 
 }

