Hello, may I know how does Abp get current time zone? I am asking because for my own created entity, it shows 8 hour slower than my time zone, while the entity that asp zero create is 3 hour slower than my time zone... this is when I'm checking the database. My time zone is +8 gmt.
Thank you
6 Answer(s)
-
0
hi,
there's doc about timezone <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Timing">https://aspnetboilerplate.com/Pages/Documents/Timing</a>
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hello, may I know specifically where to set the timezone? I read in the docs
You can set Clock.Provider in order to use a different clock provider: Clock.Provider = ClockProviders.Utc; This is generally done at the beginning of an application (proper to do it Application_Start in a web application).
however, I still do not know exactly where to set it. I want the time to be consistent throughout the application, so it always saves as UTC time in the database.
I am using .net core and angular. Thanks.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi @soonjoo,
You can do it in Startup.cs of your project.
Thanks.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
is it correct I do it here in the constructor of startup.cs?
public class Startup { private const string DefaultCorsPolicyName = "localhost"; private readonly IConfigurationRoot _appConfiguration; public Startup(IHostingEnvironment env) { _appConfiguration = env.GetAppConfiguration(); Clock.Provider = ClockProviders.Utc; } ... ... ... }Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi @soonjoo,
Yes you can do it like this, but we prefer to do it in ConfigureServices method.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
@ismcagdas,
We have used DateTime.UtcNow to populate all of our custom datetime fields. But the ABP fields (CreationTime, DeletionTime, LastModificationTime) all use local time. Our current work-around is to run our Azure servers in UTC, which assures that all DateTime fields are stored in UTC. But it's time to make a proper fix.
We are using AspNetZero v8.4, Abp 5.5, Mvc/jQuery.
Will you please provide an example of how to change the clock provider in ConfigureServices?
Based upon earlier posts in this thread, it looks like we should go back and replace all "DateTime.UtcNow" references with "ClockProviders.Utc.Now". Do you advise that change?
Thanks, BigC
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)