Base solution for your next web application
Open Closed

How to set default timezone #7240


User avatar
0
velu created

Hi,

We are using .netCore and Angular 6

How to set default timezone in .netcore [Server Side] like Indian Standard Time.

When user enter data from any timezone, Then system should apply and store date in database with default timezone [Indian Standard Time]

Thanks


3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    If the time zone between the user and the server is inconsistent, it seems to be a problem, you should consider using UTC.

    Document:https://aspnetboilerplate.com/Pages/Documents/Timing

  • User Avatar
    0
    leonkosak created

    I have question, because I do not completely understand how these timezone things are working. Currently, I have ANZ 6.3-based app (.NET Core + Angular 7 - moment 2.22.2, moment-timezone 0.5.23), but I belive that this applies identically to the latest version of ANZ. There is NO CHANGES for Clock provider (https://aspnetboilerplate.com/Pages/Documents/Timing) in Startup.cs (so "UnspecifiedClockProvider" is used), which I can confirm based on brakepoints in Application projects for Clock.Kind, Clock.SupportsMultipleTimezone and Clock.Provider values.

    On dx-date-box (DevExtreme component), there is moment.Moment variable connected and when this variable is sent to backend (AppService) (completely unmodified in typescript), we can see UTC value for DateTime on C# side model (our thimezone is +2). So accepted value is 2 hours behind. However, I noticed, that this DateTime propery (on C# side) has property "Kind" value "Utc". https://docs.microsoft.com/en-us/dotnet/api/system.datetime.kind?view=netcore-2.2

    So, how C# backed (DateTime propery in accepted model) has information about "Utc kind" of datetime (provided from moment.Moment variable on Angular side)?

  • User Avatar
    0
    maliming created
    Support Team

    You should set the Clock.Provider to ClockProviders.Utc;

    Then use moment in angular to handle the time because it has already set the time zone.