Docker Container AspNet Runtime DateTime is Wrong


Question: Why is DateTime wrong in the SQL Server when using AspNet 6 Docker Image Runtime? The time is logged as Universal Time instead of Local Time (Eastern Time). The time that is logged into the Database is UTC instead of Local Time which is Eastern Time.


Login to See the Rest of the Answer

Answer: AspNet Docker Image (Runtime) does not come with Culture Libraries installed by default. If you want time to be correct in the Asp.Net Core Docker Image on Linux then you need to add Time Zone into the Docker AspNet Image when you are building the image.

[NB]: Right before the WORKDIR /app command in the Dockerfile, paste the following above the WORKDIR /app

RUN ln -snf /usr/share/zoneinfo/America/Detroit /etc/localtime && America/Detroit ? /etc/timezone

Let us know in the comments if this helped you.






© 2024 - ErnesTech - Privacy
E-Commerce Return Policy