Converting local time to UTC

Discussion in 'ASP General' started by Elie Grouchko, Nov 13, 2004.

  1. Hi All

    1. I need to convert the local-time of the server on which I run my website
    to UTC and I don't want to rely on the server local time and timezone (i.e.
    I don't want to hardcode the timezone information), is there a generic way
    to do this?
    2. Is there a general for converting time between timezones in ASP?

    Many thanks

    Elie Grouchko
     
    Elie Grouchko, Nov 13, 2004
    #1
    1. Advertising

  2. Elie Grouchko

    Evertjan. Guest

    Elie Grouchko wrote on 13 nov 2004 in
    microsoft.public.inetserver.asp.general:

    > 1. I need to convert the local-time of the server on which I run my
    > website to UTC and I don't want to rely on the server local time and
    > timezone (i.e. I don't want to hardcode the timezone information), is
    > there a generic way to do this?
    >


    Use an ASP jscript function:

    <%
    '' vbscript:
    response.write currentUTC()
    %>

    <script language=jscript runat=server>
    function currentUTC(){
    var d, s;
    d = new Date();
    s = "Server current UTC time is: ";
    s += d.toUTCString();
    return(s);
    }
    </script>


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress,
    but let us keep the discussions in the newsgroup)
     
    Evertjan., Nov 13, 2004
    #2
    1. Advertising

  3. This relies on the client's computer time being correct, I'm looking for a
    solution that doesn't rely on the client settings.


    "Evertjan." <> wrote in message
    news:Xns95A0CF90A92AFeejj99@194.109.133.29...
    > Elie Grouchko wrote on 13 nov 2004 in
    > microsoft.public.inetserver.asp.general:
    >
    > > 1. I need to convert the local-time of the server on which I run my
    > > website to UTC and I don't want to rely on the server local time and
    > > timezone (i.e. I don't want to hardcode the timezone information), is
    > > there a generic way to do this?
    > >

    >
    > Use an ASP jscript function:
    >
    > <%
    > '' vbscript:
    > response.write currentUTC()
    > %>
    >
    > <script language=jscript runat=server>
    > function currentUTC(){
    > var d, s;
    > d = new Date();
    > s = "Server current UTC time is: ";
    > s += d.toUTCString();
    > return(s);
    > }
    > </script>
    >
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress,
    > but let us keep the discussions in the newsgroup)
    >
     
    Elie Grouchko, Nov 13, 2004
    #3
  4. Elie Grouchko

    Evertjan. Guest

    Elie Grouchko wrote on 13 nov 2004 in
    microsoft.public.inetserver.asp.general:
    > "Evertjan." <> wrote in message
    >> Elie Grouchko wrote on 13 nov 2004 in
    >> microsoft.public.inetserver.asp.general:
    >>
    >> > 1. I need to convert the local-time of the server on which I run my
    >> > website to UTC and I don't want to rely on the server local time
    >> > and timezone (i.e. I don't want to hardcode the timezone
    >> > information), is there a generic way to do this?
    >> >

    >>
    >> Use an ASP jscript function:
    >>
    >> <%
    >> '' vbscript:
    >> response.write currentUTC()
    >> %>
    >>
    >> <script language=jscript runat=server>
    >> function currentUTC(){
    >> var d, s;
    >> d = new Date();
    >> s = "Server current UTC time is: ";
    >> s += d.toUTCString();
    >> return(s);
    >> }
    >> </script>
    >>

    > This relies on the client's computer time being correct, I'm looking
    > for a solution that doesn't rely on the client settings.


    [topposting corrected]

    No, you are wrong, Elie.

    The above is totally serverside code,
    no clientside code or clock is involved.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress,
    but let us keep the discussions in the newsgroup)
     
    Evertjan., Nov 13, 2004
    #4
  5. Hi

    Sorry, my mistake :)


    "Evertjan." <> wrote in message
    news:Xns95A164B3EDF8eejj99@194.109.133.29...
    > Elie Grouchko wrote on 13 nov 2004 in
    > microsoft.public.inetserver.asp.general:
    > > "Evertjan." <> wrote in message
    > >> Elie Grouchko wrote on 13 nov 2004 in
    > >> microsoft.public.inetserver.asp.general:
    > >>
    > >> > 1. I need to convert the local-time of the server on which I run my
    > >> > website to UTC and I don't want to rely on the server local time
    > >> > and timezone (i.e. I don't want to hardcode the timezone
    > >> > information), is there a generic way to do this?
    > >> >
    > >>
    > >> Use an ASP jscript function:
    > >>
    > >> <%
    > >> '' vbscript:
    > >> response.write currentUTC()
    > >> %>
    > >>
    > >> <script language=jscript runat=server>
    > >> function currentUTC(){
    > >> var d, s;
    > >> d = new Date();
    > >> s = "Server current UTC time is: ";
    > >> s += d.toUTCString();
    > >> return(s);
    > >> }
    > >> </script>
    > >>

    > > This relies on the client's computer time being correct, I'm looking
    > > for a solution that doesn't rely on the client settings.

    >
    > [topposting corrected]
    >
    > No, you are wrong, Elie.
    >
    > The above is totally serverside code,
    > no clientside code or clock is involved.
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress,
    > but let us keep the discussions in the newsgroup)
    >
     
    Elie Grouchko, Nov 15, 2004
    #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. Kevin Frey
    Replies:
    0
    Views:
    619
    Kevin Frey
    Nov 30, 2006
  2. Replies:
    1
    Views:
    807
    Paul Boddie
    Mar 11, 2007
  3. Matt
    Replies:
    1
    Views:
    270
    i3dmaster
    Jul 6, 2007
  4. Jonathan Wood
    Replies:
    1
    Views:
    2,207
    Jonathan Wood
    Nov 1, 2009
  5. Dilip

    Converting from UTC to "local" time

    Dilip, Apr 11, 2012, in forum: C Programming
    Replies:
    20
    Views:
    1,549
    Keith Thompson
    Jun 29, 2012
Loading...

Share This Page