var evtDate = new Date('11/28/2002 07:53:40 AM');
var curDate = new Date('11/28/2002 07:53:40 AM');
var milliseconds = evtDate.getTime() - curDate.getTime();
var seconds = milliseconds / 1000;
var minutes = seconds / 60;
var hours = minutes / 60;
alert(Math.floor(hours));
is this what is should be?
when i test the page it only displays a prompt window with 0 in it (duh because no hours have gone by ^_^) but what I meant was like this:
See http://developer.netscape.com/docs/m...jsref/date.htm for details for using the Date() constructor. And note that you can use other date formats. The one that Mr. Clark is not necessarily universally recognized.
There is a very real problem with the mm/dd/yyyy format; it's not always possible to distinguish it from dd/mm/yyyy, another perfectly valid and common format. You're much better off using one of the standard date formats:
IETF: Mon, 25 Dec 1995 13:30:00 GMT
ISO 8601: 1994-11-05T08:15:30-05:00
ISO 8601 being the preferred format in HTML 4.01, you might want to use the later ( http://www.w3.org/TR/html4/types.html#type-datetime ) but the closest thing to a format that's guaranteed to work with the JavaScript Date() constructor is the former. But if you want to be certain that your constructor will work (when JavaScript works) then use Date(2002, 10, 29).
Bookmarks