Hello Support,
We are facing an issue that the application is considering the UTC time zone for each activity, but we want to use the EST timezone. User can access the application is any time zone, but we want that application will use the EST timezone. Could you please help us how we can achieve this?
Thanks
10 Answer(s)
-
0
Hi,
Please take a look at this topic Hi,
Please take a look at this topic <a class="postlink-local" href="http://forum.aspnetboilerplate.com/viewtopic.php?f=6&t=325&p=1053&hilit=utc#p1053">viewtopic.php?f=6&t=325&p=1053&hilit=utc#p1053</a>. And this issue on ABP <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/40#issuecomment-92051308">https://github.com/aspnetboilerplate/as ... t-92051308</a>.
Basically you need to change Clock.Provider with your implementation of IClockProvider.. And this issue on ABP <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/40#issuecomment-92051308">https://github.com/aspnetboilerplate/as ... t-92051308</a>.
Basically you need to change Clock.Provider with your implementation of IClockProvider.
-
0
How can we use the IClockProvider Interface/Clock class. As On the create event we are using the below code.
var history = input.MapTo<TrIncentiveActivityHistory>(); await _incentiveActivityHistoryRepository.InsertAsync(history);
The above code is saving the system's datetime for CreationTime. But I would like to change this in a specific time zone.
Thanks
-
0
Hi,
If your entity implements IHasCreationTime, ABP automatically sets CreationTime to Clock.Now. See SetCreationAuditProperties method here <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/a7cc09f5b1541b8543b91c6e74134a06d09c6ea7/src/Abp.EntityFramework/EntityFramework/AbpDbContext.cs">https://github.com/aspnetboilerplate/as ... Context.cs</a>.
If you look at the Clock class in ABP(<a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/0762989fcd0493e8dc55a50a7443e891d1bffe1f/src/Abp/Timing/Clock.cs">https://github.com/aspnetboilerplate/as ... g/Clock.cs</a>), you will see
public static DateTime Now { get { return Provider.Now; } }
So, if you change Clock.Provider with your implementation, you can achieve what you want.
I hope this helps.
-
0
Thanks for your reply, I have a confusion how can we implement this.
Clock.cs is placed under namespace Abp.Timing and this name space is placed under Abp.dll. In the project Abp.dll is already added then how can we change this.
Thanks
-
0
Hi,
Just set Clock.Provider to your implementation in Global.asax or your web module's initialize method.
Clock.Provider = new LocalClockProvider();
-
0
If using asp.net zero template, by default, the server is running on UTC.
Global.asax.cs is set with Clock.Provider = ClockProvders.Utc
To use local time, the line of code to be removed according to the code comments.
This seems to be different from the online documentation for ASP.NET ZERO, stating "... default startup solution does not enable UTC datetimes.."
Thanks. /tommy
-
0
<cite>tteoh: </cite> If using asp.net zero template, by default, the server is running on UTC.
Global.asax.cs is set with Clock.Provider = ClockProvders.Utc
To use local time, the line of code to be removed according to the code comments.
This seems to be different from the online documentation for ASP.NET ZERO, stating "... default startup solution does not enable UTC datetimes.."
Thanks. /tommy
Correction:
AspNet Zero default setting: Global.asax.cs is set with Clock.Provider = ClockProviders.Utc
Remove or comment the line: System will default to ClockProvider.Unspecified
To use local server time: ClockProvider.Local
My understanding so far.
/tommy
-
0
Hi @tteoh,
Thanks for sharing your findings. Do you use AspNet Zero template ? Normally UnspecifiedClockProvider should be default in the latest version.
Thanks.
-
0
<cite>ismcagdas: </cite> Hi @tteoh,
Thanks for sharing your findings. Do you use AspNet Zero template ? Normally UnspecifiedClockProvider should be default in the latest version.
Thanks.
Yes. I use AspNet Zero template. The Global.asax is set to use UTC. There is a comment states to remove the line of code if UTC is not required.
/tommy
-
0
Hi @tteoh,
Thanks for the information. It was like that in previous versions but in current version we removed it and default clock provider is Unspecified right now.