Date.parse() (Method/static)

A class based factory method for converting strings to Date objects.

Availability:

ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Netscape Enterprise Server - 2.0
Opera - 3.0
Property/method value type:UTC time value
JavaScript syntax:-Date.parse(aString)
Argument list:aStringA string containing a meaningful date value

The argument used with the Date.parse() method should process any string containing a sequence of characters that represents a meaningful date value. The parse() method then tokenizes that string and converts the value to a number in UTC time coordinates corresponding to the date and time in the string.

The string may be interpreted as a local time, UTC time, or a time in some other time zone depending on the contents of the string.

The result of this method is a UTC time value.

Example code:

   <HTML>

   <HEAD>

   </HEAD>

   <BODY>

   <DIV ID="RESULT1">???</DIV>

   <DIV ID="RESULT2">???</DIV>

   <FORM>

   <HR>

   <SELECT ID="IN1">

   <OPTION VALUE="Sun">Sunday

   <OPTION VALUE="Mon">Monday

   <OPTION VALUE="Tue">Tuesday

   <OPTION VALUE="Wed">Wednesday

   <OPTION VALUE="Thu">Thursday

   <OPTION VALUE="Fri">Friday

   <OPTION VALUE="Sat">Saturday

   </SELECT>

   <INPUT ID="IN2" TYPE="text" VALUE="1" SIZE="2">

   <SELECT ID="IN3">

   <OPTION VALUE="Jan">January

   <OPTION VALUE="Feb">February

   <OPTION VALUE="Mar">March

   <OPTION VALUE="Apr">April

   <OPTION VALUE="May">May

   <OPTION VALUE="Jun">June

   <OPTION VALUE="Jul">July

   <OPTION VALUE="Aug">August

   <OPTION VALUE="Sep">September

   <OPTION VALUE="Oct">October

   <OPTION VALUE="Nov">November

   <OPTION VALUE="Dec">December

   </SELECT>

   <INPUT ID="IN4" TYPE="text" VALUE="2000" SIZE="4">

   <INPUT ID="IN5" TYPE="text" VALUE="12" SIZE="2">:

   <INPUT ID="IN6" TYPE="text" VALUE="00" SIZE="2">:

   <INPUT ID="IN7" TYPE="text" VALUE="00" SIZE="2">

   <INPUT ID="IN8" TYPE="text" VALUE="+0000" SIZE="5">

   <HR>

   <INPUT TYPE="button" VALUE="CLICK ME" onClick="clickMe()">

   </FORM>

   <SCRIPT>

   function clickMe()

   {

   parseInput  = document.all.IN1.value;

   parseInput += " ";

   parseInput += document.all.IN2.value;

   parseInput += " ";

   parseInput += document.all.IN3.value;

   parseInput += " ";

   parseInput += document.all.IN4.value;

   parseInput += " ";

   parseInput += document.all.IN5.value;

   parseInput += ":";

   parseInput += document.all.IN6.value;

   parseInput += ":";

   parseInput += document.all.IN7.value;

   parseInput += " ";

   parseInput += document.all.IN8.value;

   document.all.RESULT1.innerText = parseInput;

   

   document.all.RESULT2.innerText = Date.parse(parseInput);

   }

   </SCRIPT>

   </BODY>

   </HTML>

See also:Cast operator, Date constant, Date.constructor

Cross-references:

ECMA 262 edition 2 - section - 15.9.4.2

ECMA 262 edition 3 - section - 15.9.4.2