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.


Please 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.


Write an Article
If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.


© 2022 - ErnesTech - Privacy