This articles precisely discusses this.
// convert text to date.
var date = new Date(“2/12/2012”);
// Or lets say I have a text box with an id “dateTxt” then I shall write
var dateValue = document.GetElementById(‘dateTxt’);
var date = new Date(dateValue.value);
The Date object is used to work with dates and times. Date objects are created with the Date() constructor.There are four ways of initiating a date:
var today = new Date()
var da = new Date(“October 12, 1995 11:13:00”)
var db = new Date(79,5,24)
var dc = new Date(79,5,24,11,33,0)
Here is a more detailed read.