简体   繁体   English

Web 部署在 Azure 上的应用程序未返回 UTC 日期时间

[英]Web App deployed on Azure not returning datetimes in UTC

I have deployed a backend microservice in .net core 3 on Azure and am returning a list of datetime values which i have converted to UTC using ToUniversalTime() method.我已经在 Azure 上的 .net 核心 3 中部署了一个后端微服务,并返回了一个日期时间值列表,我使用ToUniversalTime()方法将其转换为 UTC。 For some reason the datetimes returned are not converted to UTC and are the same values stored in db.由于某种原因,返回的日期时间不会转换为 UTC,并且与存储在 db 中的值相同。 It works well when i run it locally.当我在本地运行它时效果很好。

By default, Azure Web Apps run in UTC timezone.默认情况下,Azure Web 应用程序在 UTC 时区运行。 So for the application, a local time that is read from the database is interpreted to be UTC, hence calling ToUniversalTime does not change the value.因此对于应用程序,从数据库读取的本地时间被解释为 UTC,因此调用 ToUniversalTime 不会更改该值。 You can specify the timezone for the Web App using the WEBSITE_TIME_ZONE setting as described here: https://www.jasongaylord.com/blog/tip-changing-an-azure-app-service-time-zone您可以使用 WEBSITE_TIME_ZONE 设置为 Web 应用程序指定时区,如下所述: https://www.jasongaylord.com/blog/tip-sharing-an-azure-app-service-time-zone

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 新部署的 Azure Web 应用程序返回 404 错误代码 - New deployed Azure web app is returning 404 Error code 部署在Azure Web App / Azure API上时缺少CORS标头 - CORS headers missing when deployed on Azure Web App / Azure API Azure function 应用程序在从部署的 web 应用程序调用时未触发 - Azure function app is not triggering while calling from deployed web app ChakraCore.dll部署到Azure Web App时出现异常 - ChakraCore.dll Exception when deployed to Azure Web App 在Azure上部署的.net Web应用程序中存储和执行二进制文件的最佳方法 - best way to store and execute binaries in a .net web app deployed on azure 在已部署到Azure的Web应用程序中确定登录的用户是否是AD组的成员 - Determine if a logged in user is a member of an AD group, in a web app deployed to Azure Application Insights 自部署到 Azure Web 应用程序后没有数据 - Application Insights No data since deployed to Azure web app RestSharp将Datetimes转换为UTC - RestSharp converts Datetimes to UTC 所有日期时间都存储在utc中 - All datetimes stored in utc 部署到Azure的Azure Web App System.UnauthorizedAccessException无法访问本地网络上的共享文件夹 - Azure Web App System.UnauthorizedAccessException once deployed to Azure can't access shared folder on local network
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM