Locale / DateTime Problem

G

Guest

Hi,

I have a simple page which reads date from a datetime column in database.
Date stored in the database is in 'mmddyyy' format ('7/27/2005 07:30:00 AM')
but the asp.net displays it as '27/07/2005 7:30:00 AM'.

I have checked and corrected locales to US - English, but I still get this
problem.

Any help? clues?

Thnx
 
J

Juan T. Llibre

That would work.

If an application-wide setting is wanted, use :

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

in web.config.
 
G

Guest

Thanks Hugo,

That worked, but is there any thing else I could do other than putting
'en-US' as the page directive?

Thnx
 
H

Hugo Flores

I think Juan's solution works better if you don't want to bother
putting this code on each page you have. In my own experience, I have
found very odd that changing the locales is not good enough for the
server to know that everything should be in the locale that you
specified.
 
J

Juan T. Llibre

Hi, Hugo.

re:
I have found very odd that changing the locales is not good enough
for the server to know that everything should be in the locale that you
specified.

The reason for that is that it's not IIS which returns ASP.NET pages.

aspx and other asp.net source pages are processed/returned by
the aspnet_isapi dll through either w3wp.exe or wp_aspnet.exe.

The IIS server has no way of knowing what asp.net code is up to.
 
J

Juan T. Llibre

By the default globalization values in machine.config :

culture="[Culture]" - default Thread.CurrentCulture
uiCulture="[Culture]" - default Thread.CurrentUICulture

or by any values you change the default Thread.CurrentCulture
and/or Thread.CurrentUICulture to in your application's web.config.

Both CurrentCulture and CurrentUICulture
are properties of System.Globalization.CultureInfo

See:
http://www.csharpfriends.com/quicks...espace=System.Globalization&class=CultureInfo

Or, if using ASP.NET 2.0, see :
http://beta.asp.net/QUICKSTART/util...espace=System.Globalization&class=CultureInfo
 
G

Guest

Hi,
the information provided by you is helpful. But what if in some places only
Date is displayed and in some places the date along with the time?
in this case how locale will help?
--
K_


Juan T. Llibre said:
By the default globalization values in machine.config :

culture="[Culture]" - default Thread.CurrentCulture
uiCulture="[Culture]" - default Thread.CurrentUICulture

or by any values you change the default Thread.CurrentCulture
and/or Thread.CurrentUICulture to in your application's web.config.

Both CurrentCulture and CurrentUICulture
are properties of System.Globalization.CultureInfo

See:
http://www.csharpfriends.com/quicks...espace=System.Globalization&class=CultureInfo

Or, if using ASP.NET 2.0, see :
http://beta.asp.net/QUICKSTART/util...espace=System.Globalization&class=CultureInfo







Hugo Flores said:
So how does the aspnet_isapi dll know what date format to show?
 
H

Hugo Flores

Juan,
When is the machinge.config set up to have a specific locale? Is it
when you install the framewok, and then it takes the locale that you
have at the time that you install it?
 
J

Juan T. Llibre

Both Date and Time values will be displayed in the
correct format for the declared culture, regardless
of whether they are displayed together or individually.






Paraki said:
Hi,
the information provided by you is helpful. But what if in some places only
Date is displayed and in some places the date along with the time?
in this case how locale will help?
--
K_

Juan T. Llibre said:
By the default globalization values in machine.config :

culture="[Culture]" - default Thread.CurrentCulture
uiCulture="[Culture]" - default Thread.CurrentUICulture

or by any values you change the default Thread.CurrentCulture
and/or Thread.CurrentUICulture to in your application's web.config.

Both CurrentCulture and CurrentUICulture
are properties of System.Globalization.CultureInfo

See:
http://www.csharpfriends.com/quicks...espace=System.Globalization&class=CultureInfo

Or, if using ASP.NET 2.0, see :
http://beta.asp.net/QUICKSTART/util...espace=System.Globalization&class=CultureInfo







Hugo Flores said:
So how does the aspnet_isapi dll know what date format to show?
 
J

Juan T. Llibre

I am not entirely sure when, but I know -for sure- that wherever
it takes its cue from, it's not from the Control Panel's regional settings.

Remember that "culture" and "region" are different settings.

I have my Control Panel Regional settings set to "Spanish-Dominican Republic".
That should equate to "es-DO" for "culture".

It doesn't.

The short date format for Spanish-Dominican Republic is 21/06/2005

Look at what is displayed when the default culture is used on my server :

http://asp.net.do/culture.aspx

Surprise! It's displayed as English-US : 6/21/2005

Now look how it's displayed when I include "es-DO" in web.config :

http://asp.net.do/test/culture.aspx

That displays the date in the correct short date format
for Spanish-Dominican Republic : 21/06/2005

I think that culture defaults to whatever primary culture is
for the *language* the .Net Framework being installed is in.
 

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,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top