- PreConfigureServices方法重载并添加如下代码
[DependsOn(
typeof(AbpAutofacModule),
typeof(AbpAspNetCoreMvcModule),
)]
public class ApiHostModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpClockOptions>(options =>
{
options.Kind = DateTimeKind.Utc; //use utc time
});
}
}
- 服务中注册IClock时间服务
public class UserAppService : ApplicationService
{
private IClock _clock => LazyServiceProvider.LazyGetRequiredService<IClock>();
public async Task<Guid> AddAsync(InputDto inputDto)
{
inputDto.CreateTime = _clock.Now;
}
}
标签:VNext,UTC,clock,inputDto,Abp,public
From: https://www.cnblogs.com/mingcore/p/18555293