Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Boilerplate - How to add Timezone to user profile

The user profile page doesn't appear to allow the user to specify their timezone. How should we add this feature so the user can select and save their timezone and then have the web pages display the localised date?

Times are displaying in my browser according to the location of the server, so I edit a record at 7am local time, and it appears as if I edited it 4 hours in the future :)

Best solution for me is to allow the user to specify their timezone on their profile and then have this setting reflected in times displayed in the UI.

like image 372
Chris Avatar asked Sep 06 '25 03:09

Chris


2 Answers

I'm set Clock.Provider to the UTC in file Startup.cs of ...Web.Host is OK

// using Abp.Timing;    
public Startup(IHostingEnvironment env)
            {
                // Set Clock.Provider as UTC:
                Clock.Provider = ClockProviders.Utc;
                //_appConfiguration = env.GetAppConfiguration();
            }

If Angular not sent date UTC you can using:

yourDate = abp.timing.convertToUserTimezone(yourDate); // to convert yourDate to date UTC.
like image 186
Tran Binh Avatar answered Sep 08 '25 00:09

Tran Binh


You need to set the Clock.Provider to the UTC clock on the server. The documentation tells you that you need to set it but doesn't really tell you where. You just need to set this during the startup process. Here is a link to the docs that touch on it briefly.

Timing Documentation

Hope that helps.

like image 31
JeffMH Avatar answered Sep 07 '25 23:09

JeffMH