Convert string to date in Javascript

Convert string to date using Javascript : At some point of time every one needs to convert a date which is in a text format (say read from a textbox) to a Javascript Date object.

This articles precisely discusses this.

{code type=javascript}

// 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);

{/code}

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:

{code type=javascript}

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)

{/code}

Here is a more detailed read.