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.
<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 |
Prev | Home | Next |
Date.length | Up | Date.prototype |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |