ASP time in GMT

Discussion in 'ASP General' started by Abs, Mar 13, 2007.

  1. Abs

    Abs Guest

    Hello,

    I've used this ASP funtion to display the time on my web page:

    Date: <%= FormatDateTime(Date, 1)%>
    Time: <%= FormatDateTime(now, 4)%>

    THis was working fine until i moved my site to a server based in the states,
    not the time is 5hrs behind. Can anyone help me resolve this??

    Many thanks.

    Abs
     
    Abs, Mar 13, 2007
    #1
    1. Advertising

  2. Abs

    Evertjan. Guest

    Abs wrote on 13 mrt 2007 in microsoft.public.inetserver.asp.general:

    > Hello,
    >
    > I've used this ASP funtion to display the time on my web page:
    >
    > Date: <%= FormatDateTime(Date, 1)%>
    > Time: <%= FormatDateTime(now, 4)%>
    >
    > THis was working fine until i moved my site to a server based in the
    > states, not the time is 5hrs behind. Can anyone help me resolve
    > this??


    It would be usefull if you told us your timezone!

    This topic was posted by me yesterday in his NG,

    The server being in Toronto [Now],
    the result in Central European Time [nowCET].
    > ==================================
    > <%
    > nowGMT = DateAdd("h", TimezoneOffset, Now)
    > nowCET = DateAdd("h", 1, nowGMT)
    > If nowGMT>#2007-03-25 01:00# Then nowCET = DateAdd("h",2,nowGMT)
    > If nowGMT>#2007-10-28 01:00# Then nowCET = DateAdd("h",1,nowGMT)
    > If nowGMT>#2008-03-30 01:00# Then nowCET = DateAdd("h",2,nowGMT)
    > If nowGMT>#2008-10-26 01:00# Then nowCET = DateAdd("h",1,nowGMT)
    > %>
    >
    > <script language='javascript' runat='server'>
    > var TimezoneOffset = new Date().getTimezoneOffset()/60;
    > </script>
    > ===========================================


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Mar 13, 2007
    #2
    1. Advertising

  3. Abs

    MikeR Guest

    Abs wrote:
    > Hello,
    >
    > I've used this ASP funtion to display the time on my web page:
    >
    > Date: <%= FormatDateTime(Date, 1)%>
    > Time: <%= FormatDateTime(now, 4)%>
    >
    > THis was working fine until i moved my site to a server based in the states,
    > not the time is 5hrs behind. Can anyone help me resolve this??
    >
    > Many thanks.
    >
    > Abs
    >
    >

    http://classicasp.aspfaq.com/date-t...-do-i-convert-local-time-to-utc-gmt-time.html
    Mike
     
    MikeR, Mar 13, 2007
    #3
  4. Abs

    Evertjan. Guest

    Jon Paal [MSMD] wrote on 14 mrt 2007 in
    microsoft.public.inetserver.asp.general:

    > "Abs" <> wrote in message
    >> THis was working fine until i moved my site to a server based in the
    >> states, not the time is 5hrs behind. Can anyone help me resolve
    >> this??


    [Please do not toppost on usenet]

    > ASP runs on the server and will return server time. If you want local
    > time of the user to be displayed on the page you can use client side
    > javascript .


    However, it is quite possible to add
    trusted [ ;-) ] serverside time precision to that:

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

    <script type='text/javascript'>

    var ds = <% =ds %>; // numerical UTC server
    var dc = new Date();
    dc = dc*1; // numerical UTC client
    var dif = ds-dc; // millisecs UTC difference
    dif2 = Math.floor(-dif/1000)

    document.write("Local clock error: " + dif2 + " sec.<br><br>");

    d = new Date()

    document.write("Client time being: " + d + "<br><br>");

    d = new Date(d*1+dif);

    document.write("Exact local time being: " + d );

    </script>
    ============================

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Mar 14, 2007
    #4
  5. Abs

    Abs Guest

    Thanks guys, probably use javascript.

    "Evertjan." <> wrote in message
    news:Xns98F368EB62992eejj99@194.109.133.242...
    > Jon Paal [MSMD] wrote on 14 mrt 2007 in
    > microsoft.public.inetserver.asp.general:
    >
    >> "Abs" <> wrote in message
    >>> THis was working fine until i moved my site to a server based in the
    >>> states, not the time is 5hrs behind. Can anyone help me resolve
    >>> this??

    >
    > [Please do not toppost on usenet]
    >
    >> ASP runs on the server and will return server time. If you want local
    >> time of the user to be displayed on the page you can use client side
    >> javascript .

    >
    > However, it is quite possible to add
    > trusted [ ;-) ] serverside time precision to that:
    >
    > ==========================
    > <script runat=server language=javascript>
    > var ds = new Date();
    > ds = ds*1;
    > </script>
    >
    > <script type='text/javascript'>
    >
    > var ds = <% =ds %>; // numerical UTC server
    > var dc = new Date();
    > dc = dc*1; // numerical UTC client
    > var dif = ds-dc; // millisecs UTC difference
    > dif2 = Math.floor(-dif/1000)
    >
    > document.write("Local clock error: " + dif2 + " sec.<br><br>");
    >
    > d = new Date()
    >
    > document.write("Client time being: " + d + "<br><br>");
    >
    > d = new Date(d*1+dif);
    >
    > document.write("Exact local time being: " + d );
    >
    > </script>
    > ============================
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)
     
    Abs, Mar 14, 2007
    #5
    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. Shaiboy_UK
    Replies:
    0
    Views:
    483
    Shaiboy_UK
    Oct 19, 2003
  2. Peter Rilling
    Replies:
    0
    Views:
    381
    Peter Rilling
    May 4, 2004
  3. Tharinda
    Replies:
    3
    Views:
    1,215
    peter koch
    Aug 25, 2010
  4. Shaiboy_UK

    Time/Date format and changing time to GMT

    Shaiboy_UK, Oct 19, 2003, in forum: ASP General
    Replies:
    1
    Views:
    185
    Bob Barrows
    Oct 19, 2003
  5. David Joseph Bonnici
    Replies:
    1
    Views:
    212
    Gunnar Hjalmarsson
    May 15, 2005
Loading...

Share This Page