A difference in date formats

G

gstark

Hi,
I have a difference between machines in the date formats they produce. This
one web application has this code. Me.txtRxDate.Text =
Now().ToShortDateString. On the development server, the browser displays
the date as: 2/27/2007
When I goto the production server, the same browser displays the date as:
2/27/07.

Where is this controled? It's not the "Regional and Langauge Settings",
both machines are set the same.

Greg
 
G

Guest

Hi,
I have a difference between machines in the date formats they produce. This
one web application has this code. Me.txtRxDate.Text =
Now().ToShortDateString. On the development server, the browser displays
the date as: 2/27/2007
When I goto the production server, the same browser displays the date as:
2/27/07.

Where is this controled? It's not the "Regional and Langauge Settings",
both machines are set the same.

Greg

Can it be because of different culture settings?

What Culture do you use?

Example:

<globalization culture="en-US" uiCulture="en-US"/>

or

<%@ Page Language="C#" culture="en-US" uiCulture="en-US" />
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

gstark said:
Hi,
I have a difference between machines in the date formats they produce. This
one web application has this code. Me.txtRxDate.Text =
Now().ToShortDateString. On the development server, the browser displays
the date as: 2/27/2007
When I goto the production server, the same browser displays the date as:
2/27/07.

Where is this controled? It's not the "Regional and Langauge Settings",
both machines are set the same.

Greg

It's controlled by the regional settings, but not the regional settings
of your user account. That's why you can't change it from the control panel.

IIS gets the culture settings from somewhere (perhaps an admin account,
I am not certain, and it has changed from version to version) and
creates a CultureInfo object for that culture and puts in
CultureInfo.CurrentCulture. That object is used for culture dependent
operations whenever you don't specify any culture.

You can create your own CultureInfo object and use for culture dependent
operations. You can also use CultureInfo.InvariantCulture for culture
neutral effect.

ToShortDateString doesn't have any override that takes a format
provider, but it is implemented exactly as ToString("d"), so you can use
the override of ToString that takes a format provider.

Example using a swedish culture info object, which will give the result
"2007-02-27":

Dim t As String = Now().ToString("d", new CultureInfo(1053))
 

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,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top