[英]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.