I needed to determine what the real TimeZone (CST vs CDT) was for my blog application. So here is what I came up with:
// instantiate a DateTime Object
DateTime dT = DateTime.Now;
// create a string to hold the full date and time
string pubDate = dT.ToLongDateString() + " " + dT.ToShortTimeString();
// determine if daylights savings and add the appropriate TimeZone
if(TimeZone.CurrentTimeZone.IsDaylightSavingTime(dT))
{
pubDate += " CDT";
}
else
{
pubDate += " CST";
}
Granted I am really cheating and not using the full capabilities of the DateTime Class. But time is of the essence and I needed working code without a lot of testing to get the "right code".