简体   繁体   中英

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. For some reason the datetimes returned are not converted to UTC and are the same values stored in db. It works well when i run it locally.

By default, Azure Web Apps run in UTC timezone. 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM