abpframework / abp

Open Source Web Application Framework for ASP.NET Core. Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET and the ASP.NET Core platforms. Provides the fundamental infrastructure, production-ready startup templates, application modules, UI themes, tooling, guides and documentation.
https://abp.io
GNU Lesser General Public License v3.0
12.31k stars 3.32k forks source link

DateTimeKind.Local does not take effect on linux server. #13017

Closed ArcherTrister closed 1 year ago

ArcherTrister commented 1 year ago

ABP Framework version:5.1.4 database provider:EFCore

I have configured the Timezone setting and the AbpClockOptions in my project

"Settings": {
    "Abp.Localization.DefaultLanguage": "zh-Hans",
    "Abp.Timing.TimeZone": "China Standard Time"
  }
        Configure<AbpClockOptions>(options =>
        {
            options.Kind = DateTimeKind.Local;
        });

I 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?

image

This is windows local time. image

This is Linux local time. image

maliming commented 1 year ago

Is "China Standard Time" admit by your Linux server?

Check this class on two servers.

https://github.com/abpframework/abp/blob/e3e1779de6df5d26f01cdc8e99ac9cbcb3d24d3c/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/TZConvertTimezoneProvider.cs#L9

ArcherTrister commented 1 year ago

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!

image

image

luks104 commented 1 year ago

We were having similar issues and we weren't able to solve this yet. https://github.com/abpframework/abp/issues/11510

JadynWong commented 1 year ago

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.

https://github.com/abpframework/abp/blob/120d65ef9f05e480c176332b65abca89fbbc3a32/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Clock.cs?_pjax=%23js-repo-pjax-container%2C%20div%5Bitemtype%3D%22http%3A%2F%2Fschema.org%2FSoftwareSourceCode%22%5D%20main%2C%20%5Bdata-pjax-container%5D#L7-L40

JadynWong commented 1 year ago

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);
}
ArcherTrister commented 1 year ago

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?

image

image

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

ArcherTrister commented 1 year ago

BTW,We don't need to use the TimeZoneConverter library in net6. See the doc

@maliming

ArcherTrister commented 1 year ago

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.

image

image

JadynWong commented 1 year ago

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 commented 1 year ago

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.

image image

Is this the result of adding and executing this method yourself in your application? abp does not contain this code.

ArcherTrister commented 1 year ago

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.

image image

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

ArcherTrister commented 1 year ago

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 image

ArcherTrister commented 1 year ago

@JadynWong On Windows: image

JadynWong commented 1 year ago

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.

ArcherTrister commented 1 year ago

As a contributor, I don't think it should be so arbitrary. When users of open source projects find problems, They ultimately hope to solve them, Make the project stronger. Rather than jumping to conclusions prematurely or easily closing issures.

like these issues: #11510 #12394

Test screenshots: image image

JadynWong commented 1 year ago

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?

ArcherTrister commented 1 year ago

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.

ArcherTrister commented 1 year ago

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"]
ArcherTrister commented 1 year ago

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
Loiaa commented 11 months ago

When I was running on ubuntu 20.04, I encountered the same problem. I suspect this is a Docker issue.

ArcherTrister commented 11 months ago

@Loiaa I think setting the docker environment variable TZ is fine.