none
DateTime.Now.IsDaylightSavingTime() return wrong value RRS feed

  • Question

  • I'm running a application on Windows Server 2003 when i got a TimeZone problems.

    I did the following aspx page to confirm the problem:

    <%@ Import Namespace="System.Globalization.CultureInfo" %>
    
    <%
    	System.Globalization.CultureInfo.CurrentCulture.ClearCachedData() 
    %>
    
    <%= DateTime.UtcNow %>
    <br>
    <%= DateTime.Now %>
    <br>
    <%= TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now) %>
    <br>
    <%= DateTime.Now.IsDaylightSavingTime() %>
    <br>
    <%= TimeZoneInfo.Local.IsDaylightSavingTime(DateTime.Now) %>
    <br>
    <%= TimeZone.CurrentTimeZone.StandardName %>
    <br>
    <%= TimeZone.CurrentTimeZone.DaylightName %>
    <br>
    <%= TimeZoneInfo.Local.Id %>

    This gives me the following result:

    10/01/2018 14:10:35 
    10/01/2018 11:10:35 
    -02:00:00 
    False 
    False 
    E. South America Standard Time 
    E. South America Daylight Time 
    E. South America Standard Time


    Why

    DateTime.Now.IsDaylightSavingTime()

    returns False to my timezone, while it should return True?

    Also, the DateTime.Now is returning -03:00:00 offset (no daylight saving) while it should return -02:00:00 (daylight saving)

    Running the same page on another server (also Windows Serever 2003) everithing is ok.

    Any ideas on how to fix this issue?


    Wednesday, January 10, 2018 2:08 PM

All replies

  • Hi,

    Welcome to MSDN forum.

    This forum is to talk about the installation of .net framework. I recommend you go to Microsoft asp.net forum to open a new thread to talk about the problem. Thank you for understanding.

    Best regards,

    Joyce


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, January 11, 2018 6:23 AM