Displaying Time at 10-minute Intervals

Discussion in 'Javascript' started by Rick Barr, Jun 28, 2003.

  1. Rick Barr

    Rick Barr Guest

    I'm trying to build a tee-time reservation page, and want to display
    all the available tee times on one page for a particular date. I
    simply want to list the times out in 10-minute intervals, like:

    8:30am
    8:40am
    8:50am

    Additionally, I want to be able to parse out the times that already
    have entries in my SQL database, but for now I'll settle for just
    getting the times listed.

    Thanks,

    -Rick
     
    Rick Barr, Jun 28, 2003
    #1
    1. Advertisements

  2. This is best done on the server, not with client side scripting.
    This must be done on the server, so you might as well save yourself the
    effort of mucking around with client side scripting only to have to start
    again.
     
    David Dorward, Jun 28, 2003
    #2
    1. Advertisements

  3. Rick Barr

    Evertjan. Guest

    Rick Barr wrote on 28 jun 2003 in comp.lang.javascript:
    Besides the "american" way of time being crasy,
    and Noon never being am nor pm:


    <table border=1>
    <script>
    end=false
    h=8
    m=3
    ap="0am"
    td1="<tr><td style='text-align:right;width:110px;'>"
    dd=":"
    td2="</td><td style='text-align:right;width:100px;'>Free</td></tr>"

    while (!end){
    document.write(td1+h+dd+m+ap+td2)
    m++
    if(m==6){
    m=0
    h++
    if(h==12)ap="0pm"
    if(h==13)h=1
    }
    if(ap=="0pm"&&h==9&&m==1)end=true
    }
    </script>
    </table>
     
    Evertjan., Jun 28, 2003
    #3
  4. Rick Barr

    Evertjan. Guest

    David Dorward wrote on 28 jun 2003 in comp.lang.javascript:
    Also on a server it can perfectly well be done with javascript.
     
    Evertjan., Jun 28, 2003
    #4
  5. Rick Barr

    Rick Barr Guest

    Thanks VERY much for this. It makes sense, how it works, and I did go
    ahead and make it a server-side script. Now I'll just need to work on
    filtering out the times where a record already exists.

    -Rick
     
    Rick Barr, Jun 29, 2003
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.