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

查看:22
本文介绍了在 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天全站免登陆