Click to See Complete Forum and Search --> : time clock
Makkae
11-27-2002, 02:58 PM
on this site: http://www.liquidlans.tk my site u see 'v2.0 opens in 98 hours'
I need a code to let the page deduct 1 hour every hour so that its up 2 date...
can anyone help me with this?
linkage :: www.liquidlans.tk (http://www.liquidlans.tk)
Makkae
11-28-2002, 01:04 AM
sorry for my noobness :P
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:
that this page: http://www.liquidlans.tk
in an hour would be this: http://home.wanadoo.nl/lalvanbal/index3.htm
Charles
11-28-2002, 09:00 AM
See http://developer.netscape.com/docs/manuals/js/client/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.
Charles
11-29-2002, 05:12 AM
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).
Makkae
11-29-2002, 07:54 AM
yea but now I still dont know exactly what code to use :p
can anyone one post the code with the html tags in it ^_^
and oh yea,, it's be nice if it were like this: HH:MM:SS ,,
sorry but i suck at javascript :P
Charles
11-29-2002, 09:37 AM
<script type="text/javascript">
<!--
now = new Date ();
then = new Date (2002, 10, 29, 10, 35);
// note: January is month 0
if (now <= then) {
ticsPerHour = 3600000;
ticsPerMinute = 60000;
ticsPerSecond = 1000;
ticsAway = then - now;
hoursAway = Math.floor(ticsAway/ticsPerHour);
remainder = ticsAway % ticsPerHour;
minutesAway = Math.floor(remainder/ticsPerMinute);
remainder = remainder % ticsPerMinute;
secondsAway = Math.floor(remainder/ticsPerSecond);
if (hoursAway < 10) hoursAway = '0' + hoursAway;
if (minutesAway < 10) minutesAway = '0' + minutesAway;
if (secondsAway < 10) secondsAway = '0' + secondsAway;
document.write ('<p>[::] v2.0 OPENS IN ', [hoursAway, minutesAway, secondsAway].join(':'), ' [::]</p>');
};
// -->
</script>
<noscript><p>v2.0 OPENS 29 NOVEMBER 2002 at 10:35 <acronym title="ante meridiem" lang="la">am</acronym> <acronym title="Eastern Standard Time">EST</acronym>.</p></noscript>