different datetime format on the same web server

Y

Ya Ya

I have developed a class library for a web application of mine.

When compiling the code of the class library on one development machine and
copy DLL to my web server I get dd/mm/yyyy date format when using the Now()
function.

When compiling the same code on another machine and copy the DLL to the same
web server I get mm/dd/yyyy date format.

I have not change the web.config of the application on the web server (I
only replace the DLL).

How is that possible?

Can someone help here?



Thanks

(e-mail address removed)
 
H

Herfried K. Wagner [MVP]

Ya Ya said:
I have developed a class library for a web application of mine.

When compiling the code of the class library on one development machine and
copy DLL to my web server I get dd/mm/yyyy date format when using the Now()
function.

When compiling the same code on another machine and copy the DLL to the same
web server I get mm/dd/yyyy date format.

I have not change the web.config of the application on the web server (I
only replace the DLL).

How do you convert the date to a string? Are you sure the currently
executing thread's 'CurrentCulture' is the same?
 
J

Jim M

Look in the control panel under regional and language options or Regional
settings. Make sure the date format is the same on both servers. You can
also set this in your code to ensure you always get the format you want.
Although this uses a page_load you should probably use this in global.asax

imports system.globalization

Sub Page_Load(byval sender as object, e as eventargs)

With System.Threading.Thread.CurrentThread
Dim ci As New System.Globalization.CultureInfo("en-US")
Dim dtf As DateTimeFormatInfo = New
System.Globalization.DateTimeFormatInfo
dtf.ShortDatePattern = "MM.dd.yyyy"
ci.DateTimeFormat = dtf
.CurrentCulture = ci
Response.Write(Now.ToShortDateString)
End With

End sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,228
Latest member
MikeMichal

Latest Threads

Top