I've looked and looked and can't seem to come up with the perfect solution. So, since stack overflow is perfect, this will cure my problem.
I'm getting System.String
datetimes from a server (Microsoft CRM if you care). They're in SQL format ("2010-07-23T17:14:40-04:00
"). I want to read that in as a .net System.DateTime
type with the timezone information preserved, then convert it to local time. This process happens in various timezones, and I'm having trouble staying in synch. Basically, I get lots of CRM records from CRM server (which seems to stamp all the timezones with this Brazilian time (-4)), and I want to write down in my config file the latest one I saw (so I don't go back and pick up values that I already have). I would like to write it down in local time, though. Here's a distillation
I want to take the string "2010-07-23T17:14:40-04:00
" and, run some code:
System.Datetime Get_Local_DT(string val);
that will return "2010-07-23 15:14:40
" in Central time (-6) and "2010-07-23 16:14:40
" in Eastern Time (-5). Let me know what you think.