ja******@gmail.com wrote:
Try what Thomas said, but if his instructions are somewhat confusing,
use
// if t is a Date object
var d = t;
// otherwise if t is a string like '1:00 pm', this might work
var d = new Date();
d.setTime ( Date.parse ( t ) );
*If* the above works for you, then
var d = new Date(t);
should suffice. ES3 15.9.3.2 specifies the value t to be parsed "in
exactly the same manner as for the parse method (section 15.9.4.2); let
V be the time value for this date."
However, your approach fails in my Firefox 2.0.0.6 and Internet Explorer
7, where it produces NaN for "1:00 pm"; a value of "12/12/2007", for
example, works there. "1:00 pm" works in Opera 9.22, though (and does
exactly the same as your approach). (All on Windows XP, locale de-CH.)
Since I can't find anything specified about it, it would seem that the
accepted string syntax is implementation-dependent and maybe even
locale-dependent. So this approach would be not an interoperable one
and should be avoided.
Please quote the minimum of what you are replying to, as described in
the newsgroup's FAQ notes.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not the
best source of advice on designing systems that use javascript.
-- Richard Cornford, <f8*******************@news.demon.co.uk>