C
Chris Porter
Just as I thought I was understanding doing timezone offsets I ran the
following code :
CultureInfo en = new CultureInfo("en-GB");
Thread.CurrentThread.CurrentCulture = en;
Response.Write(String.Format("culture {0}<br />",
Thread.CurrentThread.CurrentCulture.ToString()));
DateTime dt = new DateTime(2003, 11, 22, 1, 0, 0);
DateTime utcdt = dt.ToUniversalTime();
// Defines a custom string format to display the DateTime value.
// zzzz specifies the full time zone offset.
String format = "dd/MM/yyyy hh:mm:sszzz";
String str = dt.ToString(format);
Response.Write(String.Format("str: {0}<br />", str));
String utcstr = utcdt.ToString(format);
Response.Write(String.Format("utcstr: {0}", utcstr));
On my uk workstation this is the output :
culture en-GB
str: 22/11/2003 01:00:00-00:00
utcstr: 22/11/2003 01:00:00-00:00
On the server in the USA this is the output :
culture en-GB
str: 22/11/2003 01:00:00-08:00
utcstr: 22/11/2003 09:00:00-08:00
So why is the USA server showing the 8 hour timezone offset and messing up
my datetime calculations despite both showing a culture en-GB ????
Thanks in advance.
following code :
CultureInfo en = new CultureInfo("en-GB");
Thread.CurrentThread.CurrentCulture = en;
Response.Write(String.Format("culture {0}<br />",
Thread.CurrentThread.CurrentCulture.ToString()));
DateTime dt = new DateTime(2003, 11, 22, 1, 0, 0);
DateTime utcdt = dt.ToUniversalTime();
// Defines a custom string format to display the DateTime value.
// zzzz specifies the full time zone offset.
String format = "dd/MM/yyyy hh:mm:sszzz";
String str = dt.ToString(format);
Response.Write(String.Format("str: {0}<br />", str));
String utcstr = utcdt.ToString(format);
Response.Write(String.Format("utcstr: {0}", utcstr));
On my uk workstation this is the output :
culture en-GB
str: 22/11/2003 01:00:00-00:00
utcstr: 22/11/2003 01:00:00-00:00
On the server in the USA this is the output :
culture en-GB
str: 22/11/2003 01:00:00-08:00
utcstr: 22/11/2003 09:00:00-08:00
So why is the USA server showing the 8 hour timezone offset and messing up
my datetime calculations despite both showing a culture en-GB ????
Thanks in advance.