Closed ArcherTrister closed 1 year ago
Is "China Standard Time"
admit by your Linux server?
Check this class on two servers.
Is
"China Standard Time"
admit by your Linux server?
@maliming On linux "Asia/Shanghai"
should be used, but this setting doesn't work.I will check this class on two servers.
Thanks!
We were having similar issues and we weren't able to solve this yet. https://github.com/abpframework/abp/issues/11510
Hi @ArcherTrister,
I think you have to change the timezone of your linux server. The Abp.Timeing.TimeZone
setting does not affect the Clock's zone. It is only used in ApplicationConfigurationService.
If you want to get the time in the time zone defined by the application setting
protected virtual async Task<DateTime> GetApplictionNowAsync()
{
var windowsTimeZoneId = await SettingProvider.GetOrNullAsync(TimingSettingNames.TimeZone);
if (windowsTimeZoneId.IsNullOrWhiteSpace())
{
throw new AbpException($"{TimingSettingNames.TimeZone} has no value.");
}
var timeZoneInfo = TimezoneProvider.GetTimeZoneInfo(windowsTimeZoneId);
return TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, timeZoneInfo);
}
I think you must be change your linux server timezone. The
Abp.Timeing.TimeZone
setting does not affect the Clock's zone.
Hi @JadynWong ,
I don't think there is a problem with my server timezone, can you help me if there is a problem?
Shanghai GetTimeZoneInfo:
{"Id":"Asia/Shanghai","DisplayName":"(UTC+08:00) China Standard Time (Shanghai)","StandardName":"China Standard Time","DaylightName":"China Daylight Time","BaseUtcOffset":"08:00:00","AdjustmentRules":[{"DateStart":"0001-01-01T00:00:00","DateEnd":"1900-12-31T15:54:16.9999999Z","DaylightDelta":"00:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:05:00","NoDaylightTransitions":true},{"DateStart":"1900-12-31T15:54:17Z","DateEnd":"1919-04-12T15:59:59.9999999Z","DaylightDelta":"00:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1919-04-12T16:00:00Z","DateEnd":"1919-09-30T14:59:59.9999999Z","DaylightDelta":"01:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00.002","Month":1,"Week":1,"Day":1,"DayOfWeek":0,"IsFixedDateRule":true},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1919-09-30T15:00:00Z","DateEnd":"1940-05-31T15:59:59.9999999Z","DaylightDelta":"00:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1940-05-31T16:00:00Z","DateEnd":"1940-10-12T14:59:59.9999999Z","DaylightDelta":"01:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00.002","Month":1,"Week":1,"Day":1,"DayOfWeek":0,"IsFixedDateRule":true},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1940-10-12T15:00:00Z","DateEnd":"1941-03-14T15:59:59.9999999Z","DaylightDelta":"00:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1941-03-14T16:00:00Z","DateEnd":"1941-11-01T14:59:59.9999999Z","DaylightDelta":"01:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00.002","Month":1,"Week":1,"Day":1,"DayOfWeek":0,"IsFixedDateRule":true},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1941-11-01T15:00:00Z","DateEnd":"1942-01-30T15:59:59.9999999Z","DaylightDelta":"00:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1942-01-30T16:00:00Z","DateEnd":"1945-09-01T14:59:59.9999999Z","DaylightDelta":"01:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00.002","Month":1,"Week":1,"Day":1,"DayOfWeek":0,"IsFixedDateRule":true},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1945-09-01T15:00:00Z","DateEnd":"1946-05-14T15:59:59.9999999Z","DaylightDelta":"00:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1946-05-14T16:00:00Z","DateEnd":"1946-09-30T14:59:59.9999999Z","DaylightDelta":"01:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00.002","Month":1,"Week":1,"Day":1,"DayOfWeek":0,"IsFixedDateRule":true},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1946-09-30T15:00:00Z","DateEnd":"1947-04-14T15:59:59.9999999Z","DaylightDelta":"00:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1947-04-14T16:00:00Z","DateEnd":"1947-10-31T14:59:59.9999999Z","DaylightDelta":"01:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00.002","Month":1,"Week":1,"Day":1,"DayOfWeek":0,"IsFixedDateRule":true},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1947-10-31T15:00:00Z","DateEnd":"1948-04-30T15:59:59.9999999Z","DaylightDelta":"00:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1948-04-30T16:00:00Z","DateEnd":"1948-09-30T14:59:59.9999999Z","DaylightDelta":"01:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00.002","Month":1,"Week":1,"Day":1,"DayOfWeek":0,"IsFixedDateRule":true},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1948-09-30T15:00:00Z","DateEnd":"1949-04-30T15:59:59.9999999Z","DaylightDelta":"00:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1949-04-30T16:00:00Z","DateEnd":"1949-05-27T14:59:59.9999999Z","DaylightDelta":"01:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00.002","Month":1,"Week":1,"Day":1,"DayOfWeek":0,"IsFixedDateRule":true},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1949-05-27T15:00:00Z","DateEnd":"1986-05-03T17:59:59.9999999Z","DaylightDelta":"00:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1986-05-03T18:00:00Z","DateEnd":"1986-09-13T16:59:59.9999999Z","DaylightDelta":"01:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00.002","Month":1,"Week":1,"Day":1,"DayOfWeek":0,"IsFixedDateRule":true},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1986-09-13T17:00:00Z","DateEnd":"1987-04-11T17:59:59.9999999Z","DaylightDelta":"00:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1987-04-11T18:00:00Z","DateEnd":"1987-09-12T16:59:59.9999999Z","DaylightDelta":"01:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00.002","Month":1,"Week":1,"Day":1,"DayOfWeek":0,"IsFixedDateRule":true},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1987-09-12T17:00:00Z","DateEnd":"1988-04-16T17:59:59.9999999Z","DaylightDelta":"00:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1988-04-16T18:00:00Z","DateEnd":"1988-09-10T16:59:59.9999999Z","DaylightDelta":"01:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00.002","Month":1,"Week":1,"Day":1,"DayOfWeek":0,"IsFixedDateRule":true},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1988-09-10T17:00:00Z","DateEnd":"1989-04-15T17:59:59.9999999Z","DaylightDelta":"00:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1989-04-15T18:00:00Z","DateEnd":"1989-09-16T16:59:59.9999999Z","DaylightDelta":"01:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00.002","Month":1,"Week":1,"Day":1,"DayOfWeek":0,"IsFixedDateRule":true},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1989-09-16T17:00:00Z","DateEnd":"1990-04-14T17:59:59.9999999Z","DaylightDelta":"00:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1990-04-14T18:00:00Z","DateEnd":"1990-09-15T16:59:59.9999999Z","DaylightDelta":"01:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00.002","Month":1,"Week":1,"Day":1,"DayOfWeek":0,"IsFixedDateRule":true},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1990-09-15T17:00:00Z","DateEnd":"1991-04-13T17:59:59.9999999Z","DaylightDelta":"00:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1991-04-13T18:00:00Z","DateEnd":"1991-09-14T16:59:59.9999999Z","DaylightDelta":"01:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00.002","Month":1,"Week":1,"Day":1,"DayOfWeek":0,"IsFixedDateRule":true},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true},{"DateStart":"1991-09-14T17:00:00Z","DateEnd":"9999-12-31T23:59:59.9999999","DaylightDelta":"00:00:00","DaylightTransitionStart":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"DaylightTransitionEnd":{"TimeOfDay":"0001-01-01T00:00:00","Month":0,"Week":0,"Day":0,"DayOfWeek":0,"IsFixedDateRule":false},"BaseUtcOffsetDelta":"00:00:00","NoDaylightTransitions":true}],"SupportsDaylightSavingTime":true}
BTW,We don't need to use the TimeZoneConverter
library in net6.
See the doc
BTW,We don't need to use the
TimeZoneConverter
library in net6. See the doc
@maliming
If you want to get the time in the time zone defined by the application setting
protected virtual async Task<DateTime> GetApplictionNowAsync() { var windowsTimeZoneId = await SettingProvider.GetOrNullAsync(TimingSettingNames.TimeZone); if (windowsTimeZoneId.IsNullOrWhiteSpace()) { throw new AbpException($"{TimingSettingNames.TimeZone} has no value."); } var timeZoneInfo = TimezoneProvider.GetTimeZoneInfo(windowsTimeZoneId); return TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, timeZoneInfo); }
@JadynWong The settings have been made here.
Can you try to just use the console to output the current local time.
Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss z"));
Console.WriteLine(DateTime.Now.Kind.ToString());
Console.WriteLine(TimeZoneInfo.Local.Id);
If you want to get the time in the time zone defined by the application setting
protected virtual async Task<DateTime> GetApplictionNowAsync() { var windowsTimeZoneId = await SettingProvider.GetOrNullAsync(TimingSettingNames.TimeZone); if (windowsTimeZoneId.IsNullOrWhiteSpace()) { throw new AbpException($"{TimingSettingNames.TimeZone} has no value."); } var timeZoneInfo = TimezoneProvider.GetTimeZoneInfo(windowsTimeZoneId); return TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, timeZoneInfo); }
@JadynWong The settings have been made here.
Is this the result of adding and executing this method yourself in your application? abp does not contain this code.
If you want to get the time in the time zone defined by the application setting
protected virtual async Task<DateTime> GetApplictionNowAsync() { var windowsTimeZoneId = await SettingProvider.GetOrNullAsync(TimingSettingNames.TimeZone); if (windowsTimeZoneId.IsNullOrWhiteSpace()) { throw new AbpException($"{TimingSettingNames.TimeZone} has no value."); } var timeZoneInfo = TimezoneProvider.GetTimeZoneInfo(windowsTimeZoneId); return TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, timeZoneInfo); }
@JadynWong The settings have been made here.
Is this the result of adding and executing this method yourself in your application? abp does not contain this code.
This is just a configuration, not executed. See the doc
Can you try to just use the console to output the current local time.
Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss z")); Console.WriteLine(DateTime.Now.Kind.ToString()); Console.WriteLine(TimeZoneInfo.Local.Id);
@JadynWong
@JadynWong On Windows:
The Abp.Timeing.TimeZone setting does not affect the Clock's zone. It is only used in ApplicationConfigurationService.
This may not be related to abp, you can test in a project that doesn't use abp. Please check the time zone of the linux server. Possible reasons Your time zone setting is only valid for the current user.
I'm just giving my personal opinion not representing anyone, I'm replying to this issue just to help you solve this problem.
Server configuration is complex.How is your abp application deployed and running (systemd), or do you have any way to reproduce this issue?
I appreciate your help, But you still think there is no problem with abp when I have so much evidence, I think my participation is pointless, It is very uncomfortable, I think it is a normal psychology.
Eventually I use docker to solve this problem, but I still can't find the root cause of the problem.Thanks for your help! @maliming @JadynWong @luks104
This is my Dockerfile config,Note that you need to change the environment variable TZ
to your own configuration.
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY ./ .
ENV ASPNETCORE_URLS http://+:80
ENV TZ=Asia/Shanghai
EXPOSE 80
ENTRYPOINT ["dotnet", "Qing.Angular.HttpApi.Host.dll"]
BTW, I use this script also doesn't work, it's always UTC Timezone, So I add environment variables TZ
when building the image.
docker run -d --restart=always -p 80:80 oauth -e TZ=Asia/Shanghai
When I was running on ubuntu 20.04, I encountered the same problem. I suspect this is a Docker issue.
@Loiaa I think setting the docker environment variable TZ is fine.
ABP Framework version:5.1.4 database provider:EFCore
I have configured the
Timezone
setting and theAbpClockOptions
in my projectI want to use local time, When I use linux server,I found value still be stored as UTC Timezone in table ,which has 8 hours time difference.But when I use windows server, it's ok. What was wrong? Did I set the Timezone correctly? Can you help me?
This is windows local time.
This is Linux local time.