Gettime ??? for displaying server time on browser

Discussion in 'ASP General' started by Matthew Ferri, Jan 23, 2005.

  1. I'm trying to display the server time on the local browser, just as
    http://www.time.gov does it.

    Is there any sample code for JS or VB available?

    TIA,
    Matthew Ferri, Jan 23, 2005
    #1
    1. Advertising

  2. Matthew Ferri

    Assortments Guest

    becuase asp runs on the server and publishes the page to the client
    this will show you the time from the server.
    <%=time()%>
    or
    <%=Now()%>


    "Matthew Ferri" <> wrote in message
    news:xmQId.16901$...
    > I'm trying to display the server time on the local browser, just as
    > http://www.time.gov does it.
    >
    > Is there any sample code for JS or VB available?
    >
    > TIA,
    >
    >
    Assortments, Jan 23, 2005
    #2
    1. Advertising

  3. Matthew Ferri

    Bullschmidt Guest

    Something like this has worked for me:

    mintServerToOrgHourOffset = 1 ' Server is Mountain Time and org is
    Central Time.

    mvarOrgCurDtTime = DateAdd("H", mintServerToOrgHourOffset, Now())

    Best regards,
    J. Paul Schmidt, Freelance ASP Web Developer
    http://www.Bullschmidt.com
    ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Bullschmidt, Jan 26, 2005
    #3
  4. Matthew Ferri

    Evertjan. Guest

    Matthew Ferri wrote on 23 jan 2005 in
    microsoft.public.inetserver.asp.general:

    > I'm trying to display the server time on the local browser, just as
    > http://www.time.gov does it.
    >
    > Is there any sample code for JS or VB available?


    This gives running local time with server precision,
    irrespective of the server local timezone:
    [weekdays in Dutch and dd-mm-yyyy]

    =======================================

    <script runat=server language=javascript>
    ds = new Date();
    ds=ds*1;
    </script>

    <script type='text/javascript'>
    ds= <% =ds %>; // UTC server
    dc=new Date();
    dc=dc*1; // UTC client
    dif = ds-dc; // UTC difference

    //alert(dif+' is the milliseconds UTC error between server and client')

    function two(x){
    return ((x<10)?"0":"")+x
    }

    var wkdgn=["zon","maan","dins","woens","donder","vrij","zater"]

    function settijd(){
    d = new Date()
    d=new Date(d*1+dif);
    document.getElementById('tijd').innerHTML=""+
    wkdgn[d.getDay()]+"dag "+
    two(d.getDate())+"-"+two(d.getMonth()+1)+"-"+d.getYear()+
    "<br> <span style='font-size:22pt;font-weight:800;'>"+
    two(d.getHours())+":"+two(d.getMinutes())+":"+
    two(d.getSeconds())+"</span>"
    setTimeout("settijd()",1000)
    }

    </script>

    <body onload='settijd()'>
    <div id='tijd'></div>

    ==================================

    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
    Evertjan., Jan 26, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Denis Remezov
    Replies:
    3
    Views:
    282
    Daniel T.
    Aug 31, 2004
  2. Yann Laviolette

    Getdate and gettime

    Yann Laviolette, Nov 2, 2003, in forum: C Programming
    Replies:
    3
    Views:
    455
    Mike Wahler
    Nov 2, 2003
  3. Replies:
    8
    Views:
    324
  4. jny0

    GetTime() library

    jny0, Jul 23, 2010, in forum: C Programming
    Replies:
    3
    Views:
    513
    Richard Bos
    Jul 25, 2010
  5. Russ Chinoy

    getTime() bug

    Russ Chinoy, May 31, 2005, in forum: Javascript
    Replies:
    8
    Views:
    153
    Dr John Stockton
    Jun 1, 2005
Loading...

Share This Page