By mche


2016-11-17 00:20:46 8 Comments

I convert a string that represents a time in Pacific Time Zone that I am using to create a DateTime object:

var pacificDateTime = new DateTime(2016, 11, 16, 15, 0, 0) // 11/16/2016 3:00:00 PM

Using that, I create a DateTimeOffset because ultimately it becomes a bit easier to work with.

var pacificTimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
var dateTimeNoKind = new DateTime(pacificDateTime.Ticks, DateTimeKind.Unspecified)
var DateTimeOffsetValue = TimeZoneInfo.ConverTimeToUtc(dateTimeNoKind, pacificTimeZoneInfo) // 11/16/2016 11:00:00 PM

So far so good. The difference between UTC and Pacific is that UTC is ahead by 8 hours (the given time is within daylight savings).

Then I want to convert from UTC to AEST—but this is where the problem appears:

var australianEasternTimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time");
TimeZoneInfo.ConvertTime(DateTimeOffsetValue, australianEasternTimeZoneInfo) // 11/17/2016 10:00:00 AM

AEST is ahead of UTC by 10 hours. I had expected the value to be 11/17/2016 09:00:00 AM but instead I am getting an extra hour added to my result.

As a test, when I convert to PST or GMT or EST from the UTC time, they appear to convert back correctly.

I feel like I am missing something obvious or overlooking something simple?

1 comments

@Matt Johnson-Pint 2016-11-17 18:52:47

From Wikipedia's Time in Australia article:

Australian Time Zones

Australia has two eastern time zones. In the northeast, UTC+10 applies all year. In the southeast, UTC+10 applies during standard time, and UTC+11 applies during daylight time (aka summer time).

The northeast region (Queensland) uses the IANA time zone identifier "Australia/Brisbane", while the southeast region (New South Wales) uses "Australia/Sydney". These correspond to the Windows time zone identifiers: "E. Australia Standard Time" and "AUS Eastern Standard Time" respectively.

  • If you are converting for Queensland, use "E. Australia Standard Time".

  • If you are converting for New South Wales, use "AUS Eastern Standard Time".

As to the confusing nature of these identifiers, see the section about Windows time zones in the timezone tag wiki.

If you want to use the standard IANA identifiers instead, use Noda Time.

Related Questions

Sponsored Content

11 Answered Questions

11 Answered Questions

[SOLVED] Convert UTC/GMT time to local time

  • 2008-10-07 19:23:05
  • nzpcmad
  • 396627 View
  • 293 Score
  • 11 Answer
  • Tags:   c# .net datetime utc

12 Answered Questions

[SOLVED] Convert UTC datetime string to local datetime

4 Answered Questions

[SOLVED] get DateTimeOffset from DateTime (utc) and TimeZoneInfo

  • 2011-06-08 19:29:33
  • katit
  • 37665 View
  • 16 Score
  • 4 Answer
  • Tags:   c# datetime

1 Answered Questions

1 Answered Questions

1 Answered Questions

[SOLVED] java timezone name 'summer' should be 'daylight'

2 Answered Questions

[SOLVED] Java: Convert MST to EST

1 Answered Questions

[SOLVED] Convert PST to GMT Irrespective of Server Timezone with .Net DateTime

2 Answered Questions

[SOLVED] Apply DateTime offset to US Eastern Timezone

Sponsored Content