none
Problem with TimeZone.CurrentTimeZone.GetUtcOffset() in VS2012/.NET 4.5 RRS feed

  • Question

  • We noticed TimeZone.CurrentTimeZone.GetUtcOffset() returns incorrect offset for certain DateTime values when we upgraded from VS2008 to VS2012/.NET 4.5.

    For EST, the offset should be -5 when daylight saving time is false; -4 when daylight saving time is true.  However, when the date 11/1/2002 11:33:40 PM is used, daylight saving time is false, but the offset returned by TimeZone.CurrentTimeZone.GetUtcOffset() is -4 rather than -5.

    Has anyone else seen the problem?  Any suggestions for a workaround to get the correct offset?

    The following code segment illustrates the problem and resulted in utcTime != utcTime2.

    DateTime dtLoc = new DateTime(2002, 11, 1, 23, 33, 40, DateTimeKind.Local);
    bool bIsDaylightSaving = dtLoc.IsDaylightSavingTime();
    TimeSpan zoneOffset = TimeZone.CurrentTimeZone.GetUtcOffset(dtLoc);

    DateTime utcTime = dtLoc.ToUniversalTime();
    DateTime utcTime2 = DateTime.SpecifyKind(dtLoc.Subtract(zoneOffset), DateTimeKind.Utc);


    • Edited by LukH Wednesday, December 12, 2012 8:15 PM
    Monday, December 10, 2012 9:28 PM

All replies

  • Hi Lukh,

    Welcome to the MSDN Forum.

    Does the same issue reproduce on .NET4.0?

    Here is a team which is focus on .net 4.5 compatibility, please contact it by this mail ID:

    Could you email us at netfx45compat at Microsoft dot com with following information.

      • Code that reproduces the problem.
      • Operating System

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, December 11, 2012 3:23 PM
    Moderator