universal time problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • thomasamillergoogle@yahoo.com

    #1

    universal time problem

    I am building a .net client application that will be deployed world
    wide.

    The client can schedule reminders. To do this the user picks the
    datetime he wants the reminder sent, _I convert the datetime to
    Universal time_, and it is submitted through a web service - where it
    finally saved to sql server.

    I have one local webservice for my testing purposes, I will call this
    service A.

    I have production webservice also, I will call this service B. This
    webservice is in a different timezone

    When my client uses webervice A or B to save the reminder it ends up
    as a different date in the database! Even though I converted the
    datetime to Universal _in the client application_!

    This is driving me somewhat crazy. What can I do to fix this behavior?

    I have read in many places that it is best practice to:

    - only write UTC times to the database
    - do every calculation/comparison in UTC.
    - only use local time (DST or not) to VISUALIZE to the user.
    - if user enters (local) time, IMMEDIATELY convert to UTC,
    and only save it as UTC, NEVER as local.


    Tom

  • Dave A

    #2
    Re: universal time problem

    I had a similar problem recently and it was because a computer had the right
    local time, the wrong time zone and therefore the wrong UTC time. Are the
    timezones and local times correct on the computers? (I am sure they are -
    you just have to ask this question)

    <thomasamillerg oogle@yahoo.com > wrote in message
    news:1117424788 .680864.121770@ g43g2000cwa.goo glegroups.com.. .[color=blue]
    >I am building a .net client application that will be deployed world
    > wide.
    >
    > The client can schedule reminders. To do this the user picks the
    > datetime he wants the reminder sent, _I convert the datetime to
    > Universal time_, and it is submitted through a web service - where it
    > finally saved to sql server.
    >
    > I have one local webservice for my testing purposes, I will call this
    > service A.
    >
    > I have production webservice also, I will call this service B. This
    > webservice is in a different timezone
    >
    > When my client uses webervice A or B to save the reminder it ends up
    > as a different date in the database! Even though I converted the
    > datetime to Universal _in the client application_!
    >
    > This is driving me somewhat crazy. What can I do to fix this behavior?
    >
    > I have read in many places that it is best practice to:
    >
    > - only write UTC times to the database
    > - do every calculation/comparison in UTC.
    > - only use local time (DST or not) to VISUALIZE to the user.
    > - if user enters (local) time, IMMEDIATELY convert to UTC,
    > and only save it as UTC, NEVER as local.
    >
    >
    > Tom
    >[/color]


    Comment

    • Dave A

      #3
      Re: universal time problem

      I had a similar problem recently and it was because a computer had the right
      local time, the wrong time zone and therefore the wrong UTC time. Are the
      timezones and local times correct on the computers? (I am sure they are -
      you just have to ask this question)

      <thomasamillerg oogle@yahoo.com > wrote in message
      news:1117424788 .680864.121770@ g43g2000cwa.goo glegroups.com.. .[color=blue]
      >I am building a .net client application that will be deployed world
      > wide.
      >
      > The client can schedule reminders. To do this the user picks the
      > datetime he wants the reminder sent, _I convert the datetime to
      > Universal time_, and it is submitted through a web service - where it
      > finally saved to sql server.
      >
      > I have one local webservice for my testing purposes, I will call this
      > service A.
      >
      > I have production webservice also, I will call this service B. This
      > webservice is in a different timezone
      >
      > When my client uses webervice A or B to save the reminder it ends up
      > as a different date in the database! Even though I converted the
      > datetime to Universal _in the client application_!
      >
      > This is driving me somewhat crazy. What can I do to fix this behavior?
      >
      > I have read in many places that it is best practice to:
      >
      > - only write UTC times to the database
      > - do every calculation/comparison in UTC.
      > - only use local time (DST or not) to VISUALIZE to the user.
      > - if user enters (local) time, IMMEDIATELY convert to UTC,
      > and only save it as UTC, NEVER as local.
      >
      >
      > Tom
      >[/color]


      Comment

      • William Stacey [MVP]

        #4
        Re: universal time problem

        Need some more info. Print the UTC when you create it, print the wire
        formate and print it when the service gets it before storing it and see
        where it is getting changed.

        --
        William Stacey [MVP]

        <thomasamillerg oogle@yahoo.com > wrote in message
        news:1117424788 .680864.121770@ g43g2000cwa.goo glegroups.com.. .[color=blue]
        >I am building a .net client application that will be deployed world
        > wide.
        >
        > The client can schedule reminders. To do this the user picks the
        > datetime he wants the reminder sent, _I convert the datetime to
        > Universal time_, and it is submitted through a web service - where it
        > finally saved to sql server.
        >
        > I have one local webservice for my testing purposes, I will call this
        > service A.
        >
        > I have production webservice also, I will call this service B. This
        > webservice is in a different timezone
        >
        > When my client uses webervice A or B to save the reminder it ends up
        > as a different date in the database! Even though I converted the
        > datetime to Universal _in the client application_!
        >
        > This is driving me somewhat crazy. What can I do to fix this behavior?
        >
        > I have read in many places that it is best practice to:
        >
        > - only write UTC times to the database
        > - do every calculation/comparison in UTC.
        > - only use local time (DST or not) to VISUALIZE to the user.
        > - if user enters (local) time, IMMEDIATELY convert to UTC,
        > and only save it as UTC, NEVER as local.
        >
        >
        > Tom
        >[/color]


        Comment

        • William Stacey [MVP]

          #5
          Re: universal time problem

          Need some more info. Print the UTC when you create it, print the wire
          formate and print it when the service gets it before storing it and see
          where it is getting changed.

          --
          William Stacey [MVP]

          <thomasamillerg oogle@yahoo.com > wrote in message
          news:1117424788 .680864.121770@ g43g2000cwa.goo glegroups.com.. .[color=blue]
          >I am building a .net client application that will be deployed world
          > wide.
          >
          > The client can schedule reminders. To do this the user picks the
          > datetime he wants the reminder sent, _I convert the datetime to
          > Universal time_, and it is submitted through a web service - where it
          > finally saved to sql server.
          >
          > I have one local webservice for my testing purposes, I will call this
          > service A.
          >
          > I have production webservice also, I will call this service B. This
          > webservice is in a different timezone
          >
          > When my client uses webervice A or B to save the reminder it ends up
          > as a different date in the database! Even though I converted the
          > datetime to Universal _in the client application_!
          >
          > This is driving me somewhat crazy. What can I do to fix this behavior?
          >
          > I have read in many places that it is best practice to:
          >
          > - only write UTC times to the database
          > - do every calculation/comparison in UTC.
          > - only use local time (DST or not) to VISUALIZE to the user.
          > - if user enters (local) time, IMMEDIATELY convert to UTC,
          > and only save it as UTC, NEVER as local.
          >
          >
          > Tom
          >[/color]


          Comment

          • asanford

            #6
            RE: universal time problem

            [at least in .net 1.1), System.DateTime will not serialize correctly if it's
            in UTC - it will always write the value of the DateTime object and then
            append the PC's UTC offset. So if the local pc is UTC-5, and you have a
            DateTime object that is set to 8/29/2005 @ 11:14:15am (UTC, non-utc, it
            doesn't matter, as DateTime doesn't track this info - therein lies the
            problem), it will serialize as "2005-08-29T11:14:15-05:00". Obviously, if
            you have set this to UTC, it will be wrong. So, always serialize DateTime
            objects only in local pc time.

            "thomasamillerg oogle@yahoo.com " wrote:
            [color=blue]
            > I am building a .net client application that will be deployed world
            > wide.
            >
            > The client can schedule reminders. To do this the user picks the
            > datetime he wants the reminder sent, _I convert the datetime to
            > Universal time_, and it is submitted through a web service - where it
            > finally saved to sql server.
            >
            > I have one local webservice for my testing purposes, I will call this
            > service A.
            >
            > I have production webservice also, I will call this service B. This
            > webservice is in a different timezone
            >
            > When my client uses webervice A or B to save the reminder it ends up
            > as a different date in the database! Even though I converted the
            > datetime to Universal _in the client application_!
            >
            > This is driving me somewhat crazy. What can I do to fix this behavior?
            >
            > I have read in many places that it is best practice to:
            >
            > - only write UTC times to the database
            > - do every calculation/comparison in UTC.
            > - only use local time (DST or not) to VISUALIZE to the user.
            > - if user enters (local) time, IMMEDIATELY convert to UTC,
            > and only save it as UTC, NEVER as local.
            >
            >
            > Tom
            >
            >[/color]

            Comment

            Working...