I have a date format, something similar to:
Mon, Sun, 22 Aug 2010 12:38:33 GMT
How do I convert this to EST format?
Note: I know it can be achieved using TimeZoneinfo, but that is introduced in 3.5, i want to do it 2.0 or any old version.
I have a date format, something similar to:
Mon, Sun, 22 Aug 2010 12:38:33 GMT
How do I convert this to EST format?
Note: I know it can be achieved using TimeZoneinfo, but that is introduced in 3.5, i want to do it 2.0 or any old version.
EST is probably not a format but an abbreviation of the time zone. I.e. the "manual" way would be to parse the above date and subtract the time zone difference. You should be beware of daylight saving time periods, i.e. you need to check if the above time fits the DST period or not.
I guess you have to go the old road of understanding timezones. Your example is though pretty easy.
GMT is UTC with daylight saving changes.
EST is UTC -5hrs with daylight saving changes.
So you just have to substract 5 hours to get the time in EST.
The simplest way would probably be to just take 5 hours off the time like so.
DateTime dateTime = DateTime.UtcNow;
dateTime.AddHours(-5);
But this won't account for daylight savings etc. But you could always code for that possibility.