Question

I have an issue where running code on my local machine and the server render 2 different results.

The codet that I'm calling is:

Dim t as DateTime = Date.Now
t.ToShortTimeString

On the server it is rendering as:

14:32

And on my local machine it is rendering as

2:32 PM (this is what we want it to be)

They are both setup using English as the locale. Is there any other setting on the machine that I should be checking to know what could be wrong?

This is the server language information. It shows that Short Time should be displaying as I'm expecting it to

enter image description here

Was it helpful?

Solution

The Region and Language settings for Windows are different per user. You need to determine the user account under which the web site is running and check that user's settings.

If necessary, you can use the Administrative tab to copy the settings the system accounts. This article describes, in detail, how to do that.

As others have mentioned, though, if you always want the time to be formatted in a particular way, you should not use the ToShortTimeString method. You should use one of the overrides of the ToString method to force the exact formatting that you desire, for instance:

t.ToString("hh:mm tt")    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top