Ayyash
Ayyash

Reputation: 4399

how to overwrite the timezone of the server in a sub application

This is a quicky, what do I need to setup a different timzone in my application than that setup on IIS

All i want is to show a specific date in AESP rather than SPT, ist here a way in C# .NET 3.5?

Upvotes: 0

Views: 338

Answers (2)

Ayyash
Ayyash

Reputation: 4399

I figured it out:

DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
dtfi.FullDateTimePattern = "yyyy-MM-ddTHH:mmzzz";
DateTime s = DateTime.Parse(inputstring, dtfi);
s = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(s, "AUS Eastern Standard Time");
TimeZoneInfo tzz = TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time");
string timezone = (tzz.IsDaylightSavingTime(s)) ? tzz.DaylightName : tzz.StandardName;

CultureInfo  culture = CultureInfo.CreateSpecificCulture("en-AU");
string output = String.Format("{0} | {1}", s.ToString("f", culture), timezone);

so input is: 2009-10-13T10:00-7:00
output is: Wednesday, 14 October 2009 4:00 AM | AUS Eastern Daylight Time

input is: 2009-9-13T10:00-7:00
output is: Monday, 14 September 2009 3:00 AM | AUS Eastern Standard Time

Upvotes: 0

Matt
Matt

Reputation: 3014

Try TimeZoneInfo.ConvertTime(DateTime dateTime, TimeZoneInfo sourceTimeZone, TimeZoneInfo destTimeZone)

http://msdn.microsoft.com/en-us/library/bb382770.aspx

Upvotes: 2

Related Questions