datetime conversions - US CST

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark

    datetime conversions - US CST

    Hey everybody.

    Is there an easy way in vb.net to convert the local time of a machine
    to US CST ? My machines are distributed throughout and the server is
    requesting we send the time of the txns in US CST.

    TIA,
    Mark
  • Jay B. Harlow [MVP - Outlook]

    #2
    Re: datetime conversions - US CST

    Mark,
    Unfortunately System.DateTime (VB's Date) only knows how to convert a
    Universal Time to Local Time & convert Local Time to UniversalTime.

    I would recommend that each of your machines convert local time to universal
    time, then send that time to the server. The server can then convert the
    universal time to local time which will be CST.

    You can use
    - DateTime.Now - to get current local date & time
    - DateTime.UtcNow - to get current date & time in universal time (UTC)
    - DateTime.ToUniv ersalTime - to convert local time to universal time
    - DateTime.ToLoca lTime - to convert universal time to local time


    Hope this helps
    Jay

    "Mark" <marfi95@yahoo. com> wrote in message
    news:f47c17d0.0 408241507.65f44 958@posting.goo gle.com...[color=blue]
    > Hey everybody.
    >
    > Is there an easy way in vb.net to convert the local time of a machine
    > to US CST ? My machines are distributed throughout and the server is
    > requesting we send the time of the txns in US CST.
    >
    > TIA,
    > Mark[/color]


    Comment

    • Mark

      #3
      Re: datetime conversions - US CST

      Thanks Jay.

      Unfortunately, in this environment, the server that I referred to is
      not the end location and is not in CST. For this particular txn, its
      just passing thru the message on to the final dest. So the server
      would have the same problem. I haven't looked yet, but does the
      localtime include the timezone locally also, so I would have that
      information ?

      "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP @msn.com> wrote in message news:<uGllUVliE HA.3536@TK2MSFT NGP12.phx.gbl>. ..[color=blue]
      > Mark,
      > Unfortunately System.DateTime (VB's Date) only knows how to convert a
      > Universal Time to Local Time & convert Local Time to UniversalTime.
      >
      > I would recommend that each of your machines convert local time to universal
      > time, then send that time to the server. The server can then convert the
      > universal time to local time which will be CST.
      >
      > You can use
      > - DateTime.Now - to get current local date & time
      > - DateTime.UtcNow - to get current date & time in universal time (UTC)
      > - DateTime.ToUniv ersalTime - to convert local time to universal time
      > - DateTime.ToLoca lTime - to convert universal time to local time
      >
      >
      > Hope this helps
      > Jay
      >
      > "Mark" <marfi95@yahoo. com> wrote in message
      > news:f47c17d0.0 408241507.65f44 958@posting.goo gle.com...[color=green]
      > > Hey everybody.
      > >
      > > Is there an easy way in vb.net to convert the local time of a machine
      > > to US CST ? My machines are distributed throughout and the server is
      > > requesting we send the time of the txns in US CST.
      > >
      > > TIA,
      > > Mark[/color][/color]

      Comment

      • Jay B. Harlow [MVP - Outlook]

        #4
        Re: datetime conversions - US CST

        Mark,
        In case you missed my point. I am suggesting you only send time in universal
        time between servers. I would convert local time to universal time on the
        originating systems only (not pass thru systems).

        No matter what server you are on, or how many you pass thru, the time will
        still be universal time. Hence there is no worry as to what the local time
        is!


        To answer your question, DateTime does not itself keep track as to whether
        it is in Local or Universal time you need to do this yourself. I normally do
        this via the context of the variable.

        You can use System.TimeZone .CurrentTimeZon e to find out what the current
        time zone on your system is.

        Hope this helps
        Jay


        "Mark" <marfi95@yahoo. com> wrote in message
        news:f47c17d0.0 408250550.1aacb 8f2@posting.goo gle.com...[color=blue]
        > Thanks Jay.
        >
        > Unfortunately, in this environment, the server that I referred to is
        > not the end location and is not in CST. For this particular txn, its
        > just passing thru the message on to the final dest. So the server
        > would have the same problem. I haven't looked yet, but does the
        > localtime include the timezone locally also, so I would have that
        > information ?
        >
        > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP @msn.com> wrote in message[/color]
        news:<uGllUVliE HA.3536@TK2MSFT NGP12.phx.gbl>. ..[color=blue][color=green]
        > > Mark,
        > > Unfortunately System.DateTime (VB's Date) only knows how to convert a
        > > Universal Time to Local Time & convert Local Time to UniversalTime.
        > >
        > > I would recommend that each of your machines convert local time to[/color][/color]
        universal[color=blue][color=green]
        > > time, then send that time to the server. The server can then convert the
        > > universal time to local time which will be CST.
        > >
        > > You can use
        > > - DateTime.Now - to get current local date & time
        > > - DateTime.UtcNow - to get current date & time in universal time (UTC)
        > > - DateTime.ToUniv ersalTime - to convert local time to universal time
        > > - DateTime.ToLoca lTime - to convert universal time to local time
        > >
        > >
        > > Hope this helps
        > > Jay
        > >
        > > "Mark" <marfi95@yahoo. com> wrote in message
        > > news:f47c17d0.0 408241507.65f44 958@posting.goo gle.com...[color=darkred]
        > > > Hey everybody.
        > > >
        > > > Is there an easy way in vb.net to convert the local time of a machine
        > > > to US CST ? My machines are distributed throughout and the server is
        > > > requesting we send the time of the txns in US CST.
        > > >
        > > > TIA,
        > > > Mark[/color][/color][/color]


        Comment

        Working...