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. Format date to system timezone

Format date to system timezone

Scheduled Pinned Locked Moved C#
questionhelp
2 Posts 2 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
    Tony Pottier
    wrote on last edited by
    #1

    Hi, I have DateTime objects that are all GMT+0 times. I'd like to display them in my program so that it matches system's timezone. For instance, the DateTime "2009-03-14 16:00:00" would be ouput as a string as "2009-03-14 17:00:00 (GMT+1)" if my system timezone is set to GMT+1. How can I do this? DateTime.ToString MSDN doc doesn't help; I'm not sure if there's an easy way to do this :/

    C 1 Reply Last reply
    0
    • T Tony Pottier

      Hi, I have DateTime objects that are all GMT+0 times. I'd like to display them in my program so that it matches system's timezone. For instance, the DateTime "2009-03-14 16:00:00" would be ouput as a string as "2009-03-14 17:00:00 (GMT+1)" if my system timezone is set to GMT+1. How can I do this? DateTime.ToString MSDN doc doesn't help; I'm not sure if there's an easy way to do this :/

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You need to use the locale classes to work out what the timezone is, then build your own string that shows this information. http://msdn.microsoft.com/en-us/library/system.datetimeoffset.aspx[^] is one option, the other is to convert the time to UTC, and then work out the difference.

      Christian Graus Driven to the arms of OSX by Vista.

      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