ASP Time vs. VB Client time 
Author Message
 ASP Time vs. VB Client time

The datediff function wasn't giving me a problem.  The problem is evaluating whether the server time or client time evaluates as ">".  As an old COBOL programmer, I can tell you the evaluation should be very simple.  In VB, however, the program seems to be assigning the greater value to the earlier time.  In the example below, I would expect the statement "If clienttime > servertime" to be true, but my program reaches the opposite conclusion.

    servertime = #12:15:45 PM#
    clienttime = #12:16:05 PM#

    msgbox datediff("s",servertime,clienttime)

    --
    Michael Harris


        I have an assignment to do a web page capturing the time at the server & the
        client, & computing the difference between the two.  One solution would be
        to capture the time at the client on a form & send it to the server to
        process the results & send them back, but I chose a different route.  I put
        a hidden field on a form and load it upon the initial request with ASP
        (Visual Basic) code setting the field=time.  I retrieve it at the client and
        display it, but it doesn't show AM or PM.  The time I capture in my client
        script, however (Also VB) does display the AM/PM.  This posed a problem for
        datediff, as well as an awkward display, so I captured the rightmost 3
        characters of the client time (a space character followed by AM or PM) and
        appended them to the variable with the server time.  Now they display in
        similar formats.  However,  when I compare the two variables, they evaluate
        as the server time being greater than the client time, when this is clearly
        not the case.  For example, 12:15:45 PM from the server is evaluating as
        greater than 12:16:05 PM on the client.  Any idea why the values are
        collating this way?



Mon, 22 Jul 2002 03:00:00 GMT  
 ASP Time vs. VB Client time

servertime = "12:15:45 PM"
clienttime = "12:16:05 PM"

if timevalue(servertime) > timevalue(clienttime) then
  msgbox "servertime is greater.."
else
  msgbox "servertime is not greater.."
end if

--
Michael Harris

  The datediff function wasn't giving me a problem.  The problem is evaluating whether the server time or client time evaluates as ">".  As an old COBOL programmer, I can tell you the evaluation should be very simple.  In VB, however, the program seems to be assigning the greater value to the earlier time.  In the example below, I would expect the statement "If clienttime > servertime" to be true, but my program reaches the opposite conclusion.

    servertime = #12:15:45 PM#
    clienttime = #12:16:05 PM#

    msgbox datediff("s",servertime,clienttime)

    --
    Michael Harris


      I have an assignment to do a web page capturing the time at the server & the
      client, & computing the difference between the two.  One solution would be
      to capture the time at the client on a form & send it to the server to
      process the results & send them back, but I chose a different route.  I put
      a hidden field on a form and load it upon the initial request with ASP
      (Visual Basic) code setting the field=time.  I retrieve it at the client and
      display it, but it doesn't show AM or PM.  The time I capture in my client
      script, however (Also VB) does display the AM/PM.  This posed a problem for
      datediff, as well as an awkward display, so I captured the rightmost 3
      characters of the client time (a space character followed by AM or PM) and
      appended them to the variable with the server time.  Now they display in
      similar formats.  However,  when I compare the two variables, they evaluate
      as the server time being greater than the client time, when this is clearly
      not the case.  For example, 12:15:45 PM from the server is evaluating as
      greater than 12:16:05 PM on the client.  Any idea why the values are
      collating this way?



Mon, 22 Jul 2002 03:00:00 GMT  
 ASP Time vs. VB Client time

Michael, you're giving me more good advice, but noone has addressed the real root of the problem.  If I receive time from the host with <&=Time%> and print it, I get a format such as 10:02:12 AM.  However, if I set a variable such as a hidden form field = Time, I only receive the 10:02:12, and I have a string variable with length 8, I have lost the AM or PM information.  This seems like a bug, & it happens on Personal Web Server as well as on the space I have at eWebCity.  It seems that the assignment statement should set a variable of subtype DATE and include the AM or PM information.

    servertime = "12:15:45 PM"
    clienttime = "12:16:05 PM"

    if timevalue(servertime) > timevalue(clienttime) then
      msgbox "servertime is greater.."
    else
      msgbox "servertime is not greater.."
    end if

    --
    Michael Harris

        The datediff function wasn't giving me a problem.  The problem is evaluating whether the server time or client time evaluates as ">".  As an old COBOL programmer, I can tell you the evaluation should be very simple.  In VB, however, the program seems to be assigning the greater value to the earlier time.  In the example below, I would expect the statement "If clienttime > servertime" to be true, but my program reaches the opposite conclusion.

            servertime = #12:15:45 PM#
            clienttime = #12:16:05 PM#

            msgbox datediff("s",servertime,clienttime)

            --
            Michael Harris


                I have an assignment to do a web page capturing the time at the server & the
                client, & computing the difference between the two.  One solution would be
                to capture the time at the client on a form & send it to the server to
                process the results & send them back, but I chose a different route.  I put
                a hidden field on a form and load it upon the initial request with ASP
                (Visual Basic) code setting the field=time.  I retrieve it at the client and
                display it, but it doesn't show AM or PM.  The time I capture in my client
                script, however (Also VB) does display the AM/PM.  This posed a problem for
                datediff, as well as an awkward display, so I captured the rightmost 3
                characters of the client time (a space character followed by AM or PM) and
                appended them to the variable with the server time.  Now they display in
                similar formats.  However,  when I compare the two variables, they evaluate
                as the server time being greater than the client time, when this is clearly
                not the case.  For example, 12:15:45 PM from the server is evaluating as
                greater than 12:16:05 PM on the client.  Any idea why the values are
                collating this way?



Mon, 22 Jul 2002 03:00:00 GMT  
 ASP Time vs. VB Client time

You're probably losing the AM/PM because the value isn't quoted...

<input type=hidden name=servertime value=<%= Time() %>>
<input type=hidden name=servertime value=10:02:12 AM>

The AM is treated as attribute of the input html element, not part of the value, because of the space and missing quotes (single or double)...

This what you need to send back to the client:

<input type=hidden name=servertime value="<%= Time() %>">
or
response.write "<input type=hidden name=servertime value=""" & Time() & "">"

results in

<input type=hidden name=servertime value="10:02:12 AM">

Single qoutes are OK too...

<input type=hidden name=servertime value='<%= Time() %>'>
or
response.write "<input type=hidden name=servertime value='" & Time() & '>"

results in

<input type=hidden name=servertime value='10:02:12 AM'>

--
Michael Harris


  Michael, you're giving me more good advice, but noone has addressed the real root of the problem.  If I receive time from the host with <&=Time%> and print it, I get a format such as 10:02:12 AM.  However, if I set a variable such as a hidden form field = Time, I only receive the 10:02:12, and I have a string variable with length 8, I have lost the AM or PM information.  This seems like a bug, & it happens on Personal Web Server as well as on the space I have at eWebCity.  It seems that the assignment statement should set a variable of subtype DATE and include the AM or PM information.

    servertime = "12:15:45 PM"
    clienttime = "12:16:05 PM"

    if timevalue(servertime) > timevalue(clienttime) then
      msgbox "servertime is greater.."
    else
      msgbox "servertime is not greater.."
    end if

    --
    Michael Harris

      The datediff function wasn't giving me a problem.  The problem is evaluating whether the server time or client time evaluates as ">".  As an old COBOL programmer, I can tell you the evaluation should be very simple.  In VB, however, the program seems to be assigning the greater value to the earlier time.  In the example below, I would expect the statement "If clienttime > servertime" to be true, but my program reaches the opposite conclusion.

        servertime = #12:15:45 PM#
        clienttime = #12:16:05 PM#

        msgbox datediff("s",servertime,clienttime)

        --
        Michael Harris


          I have an assignment to do a web page capturing the time at the server & the
          client, & computing the difference between the two.  One solution would be
          to capture the time at the client on a form & send it to the server to
          process the results & send them back, but I chose a different route.  I put
          a hidden field on a form and load it upon the initial request with ASP
          (Visual Basic) code setting the field=time.  I retrieve it at the client and
          display it, but it doesn't show AM or PM.  The time I capture in my client
          script, however (Also VB) does display the AM/PM.  This posed a problem for
          datediff, as well as an awkward display, so I captured the rightmost 3
          characters of the client time (a space character followed by AM or PM) and
          appended them to the variable with the server time.  Now they display in
          similar formats.  However,  when I compare the two variables, they evaluate
          as the server time being greater than the client time, when this is clearly
          not the case.  For example, 12:15:45 PM from the server is evaluating as
          greater than 12:16:05 PM on the client.  Any idea why the values are
          collating this way?



Mon, 22 Jul 2002 03:00:00 GMT  
 ASP Time vs. VB Client time

You got it!  Thanks a million.

    You're probably losing the AM/PM because the value isn't quoted...

    <input type=hidden name=servertime value=<%= Time() %>>
    <input type=hidden name=servertime value=10:02:12 AM>

    The AM is treated as attribute of the input html element, not part of the value, because of the space and missing quotes (single or double)...

    This what you need to send back to the client:

    <input type=hidden name=servertime value="<%= Time() %>">
    or
    response.write "<input type=hidden name=servertime value=""" & Time() & "">"



Mon, 22 Jul 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. server time reported on .asp web pages, how do I report client side time correctly

2. web service and updating web reference with vb.net design time vs run time

3. web service and updating web reference with vb.net design time vs run time

4. Times Greek boldface/italic and Times vs Symbol

5. Object Time Out vs. Session Time Out

6. Design time vs Run time

7. Run Time vs Design Time - No Current Record

8. Design Time vs Run Time

9. Design time vs. Run time

10. Server time vs. Network time

11. Elapsed working time vs. Actual Time

12. Time, TIME TIME

 

 
Powered by phpBB® Forum Software