在Unix(nginx)上托管时.NET Core中的TimeZoneInfo [英] TimeZoneInfo in .NET Core when hosting on unix (nginx)

查看:216
本文介绍了在Unix(nginx)上托管时.NET Core中的TimeZoneInfo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,当我尝试执行以下操作时.

For example, when I try to do the following.

TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time")

我收到错误消息,说TimeZone在本地计算机上不可用.当我在本地运行此程序时,它可以运行,但在Windows上可以运行它.部署后,它将在Nginx中的Unix计算机上运行.我可以看到FindSystemTimeZoneById在Unix上查找错误的文件夹.有什么办法可以做到这一点?

I get the error, that the TimeZone is not available on the local computer. When I run this locally it works, but there I run it on windows. When deployed it runs on a Unix machine in Nginx. I can see that FindSystemTimeZoneById is looking in the wrong folder when it comes to Unix. Is there any way to make this work?

推荐答案

.Net Core使用系统时区.不幸的是,Windows和Linux具有不同的时区系统.现在,您有两种方法:

.Net Core using system timezone. Unfortunately Windows and Linux have different timezone system. Now you have two ways:

这篇关于在Unix(nginx)上托管时.NET Core中的TimeZoneInfo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆