Why does the same DateTime give a different displayed time for different users?

In my ASP.NET application, I use the code here to find the build date of the application as UTC. The UTC value read from the assembly file is then formatted as follows:

//DateTime time return time.ToString("dd MMM yyyy HH:mm:ss"); 

Now one user opens the page served by this application and sees

 28  2012 04:13:56 

and notifies another user who opens the same page and sees

 27 Sep 2012 12:14:32 

Both requests are served by the same application that is deployed to clean up Windows Azure virtual machines from the same package, so the exact same code is executed for both users.

It is clear that strings are formatted differently due to different localization of requests from different users. One user sees the month displayed as Sep , and the other sees it as (equivalent to Sep in Russian).

Why are watches different? Are they also configured according to the time zone, which depends on the localization?

+6
source share
1 answer

The most obvious explanation is that DateTime values ​​are essentially different.

The code used uses GetCallingAssembly , and you should notice that MSDN says that:

If the method that calls the GetCallingAssembly method is extended by the Just-In-Time (JIT) built-in compiler, or if its caller is expanded by the built-in compiler, the assembly returned by GetCallingAssembly may unexpectedly differ

To debug this, I would start by displaying time.Ticks and time.Kind : if they are identical, you know that this is a display problem. If they are different, you need to see how you generate the time value.

+3
source

Source: https://habr.com/ru/post/926482/


All Articles