Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. DateTime ISO 8601 Format

DateTime ISO 8601 Format

Scheduled Pinned Locked Moved C#
databasejsontutorialannouncement
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tadhg88
    wrote on last edited by
    #1

    First of all my apologies if this is in the wrong forum, i'm sure i will find out very quickly if it is :doh: So basically i am writing an API that needs to return the running date and time of tours including the offset, this format "2016-12-05T10:00:00+02:00", these tours can be in England or Italy so they run in two different timezones and should have a different offset. Our API and DB run on servers in the US, all the running times are stored in the db as a datetime, without any offset, without anything to distinguish the timezones they run in bar the fact they are linked to different countries. I'm just wondering what the coorect process is here, i have spent ages reading up on this and i think I'm more confused than when i started. I am thinking that maybe i need to get the running date as a universal datetime and decrease this datetime for the English tours but i'm not sure how i can update the date to have a different offset, how to set/change the date so it knows its in a different timezone. Any guidance, advice or suggestions of an appropriate blog/article to put me on the correct track would really be appreciated, thanks very much in advance.

    D 1 Reply Last reply
    0
    • T tadhg88

      First of all my apologies if this is in the wrong forum, i'm sure i will find out very quickly if it is :doh: So basically i am writing an API that needs to return the running date and time of tours including the offset, this format "2016-12-05T10:00:00+02:00", these tours can be in England or Italy so they run in two different timezones and should have a different offset. Our API and DB run on servers in the US, all the running times are stored in the db as a datetime, without any offset, without anything to distinguish the timezones they run in bar the fact they are linked to different countries. I'm just wondering what the coorect process is here, i have spent ages reading up on this and i think I'm more confused than when i started. I am thinking that maybe i need to get the running date as a universal datetime and decrease this datetime for the English tours but i'm not sure how i can update the date to have a different offset, how to set/change the date so it knows its in a different timezone. Any guidance, advice or suggestions of an appropriate blog/article to put me on the correct track would really be appreciated, thanks very much in advance.

      D Offline
      D Offline
      Daniel Pfeffer
      wrote on last edited by
      #2

      IMO, you are mixing two issues, one being the storage of the time and the other being the display. Dates and times should always be stored using a common base (e.g. UTC). The exact base is irrelevant (it could just as easily be Eastern Standard Time), but it should be consistent. The display may depend on the location of the user (e.g. all the DB users are in the U.S.), the location of the tour (display in UK time or Italian time), etc. For example, airline schedules are always displayed using the local time at the origin (for takeoff) and at the destination (for landing). I hope this helps.

      If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack. --Winston Churchill

      OriginalGriffO R T 3 Replies Last reply
      0
      • D Daniel Pfeffer

        IMO, you are mixing two issues, one being the storage of the time and the other being the display. Dates and times should always be stored using a common base (e.g. UTC). The exact base is irrelevant (it could just as easily be Eastern Standard Time), but it should be consistent. The display may depend on the location of the user (e.g. all the DB users are in the U.S.), the location of the tour (display in UK time or Italian time), etc. For example, airline schedules are always displayed using the local time at the origin (for takeoff) and at the destination (for landing). I hope this helps.

        If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack. --Winston Churchill

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        :thumbsup:

        Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        • D Daniel Pfeffer

          IMO, you are mixing two issues, one being the storage of the time and the other being the display. Dates and times should always be stored using a common base (e.g. UTC). The exact base is irrelevant (it could just as easily be Eastern Standard Time), but it should be consistent. The display may depend on the location of the user (e.g. all the DB users are in the U.S.), the location of the tour (display in UK time or Italian time), etc. For example, airline schedules are always displayed using the local time at the origin (for takeoff) and at the destination (for landing). I hope this helps.

          If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack. --Winston Churchill

          R Offline
          R Offline
          Ravi Bhavnani
          wrote on last edited by
          #4

          Daniel Pfeffer wrote:

          Dates and times should always be stored using a common base (e.g. UTC). The exact base is irrelevant (it could just as easily be Eastern Standard Time), but it should be consistent.

          Spot on! :thumbsup: /ravi

          My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

          1 Reply Last reply
          0
          • D Daniel Pfeffer

            IMO, you are mixing two issues, one being the storage of the time and the other being the display. Dates and times should always be stored using a common base (e.g. UTC). The exact base is irrelevant (it could just as easily be Eastern Standard Time), but it should be consistent. The display may depend on the location of the user (e.g. all the DB users are in the U.S.), the location of the tour (display in UK time or Italian time), etc. For example, airline schedules are always displayed using the local time at the origin (for takeoff) and at the destination (for landing). I hope this helps.

            If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack. --Winston Churchill

            T Offline
            T Offline
            tadhg88
            wrote on last edited by
            #5

            Thanks for your reply, much appreciated. So based on your logic could I not say that all my times are stored in Italian time but not in UTC, then try to convert them to UTC and back to the English time just for the tours in England?

            D 1 Reply Last reply
            0
            • T tadhg88

              Thanks for your reply, much appreciated. So based on your logic could I not say that all my times are stored in Italian time but not in UTC, then try to convert them to UTC and back to the English time just for the tours in England?

              D Offline
              D Offline
              Daniel Pfeffer
              wrote on last edited by
              #6

              Yes, that would work. The advantage of using UTC for everything is that you don't need to handle switches between Daylight Saving Time and Standard Time - UTC has no Daylight Saving time. It also simplifies your code - all display times require one (and only one) conversion. Compare and contrast to the Italian --> UK case.

              If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack. --Winston Churchill

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups