dcsimg
www.webdeveloper.com
Results 1 to 6 of 6

Thread: time clock

  1. #1
    Join Date
    Nov 2002
    Posts
    3

    time clock

    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

  2. #2
    Join Date
    Nov 2002
    Posts
    3
    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

  3. #3
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    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.

  4. #4
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    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).

  5. #5
    Join Date
    Nov 2002
    Posts
    3
    yea but now I still dont know exactly what code to use

    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

  6. #6
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    <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>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles