Date/Time problems

G

Guest

Hi guys

I'm having a problem with DateTime.Now.ToShortDateString().

It works fine, but I've got 2 servers (development and production), and
while the production server works perfectly and returns a UK formatted short
date (dd/mm/yyyy), my development server returns the US format (mm/dd/yyyy).

Both servers are Win2k3 with .net2.0 (2.0.50727) and I've checked date/time
settings and regional settings from Control Panel on both servers and they're
exactly the same.

What's going on? Why is DateTime giving US formats? Is there something I
need to change in the .net framework?

Help, this is really annoying!
 
G

Galin iliev

Are you sure Regional Settings are exacly same?

you can use custom format with
string.Format("dd/mm/yyyy", DateTime.Now)

or
string.Format("dd/MM/yyyy", DateTime.Now)

Hope this helps
 
W

Walter Wang [MSFT]

Hi,

Thank you for posting!

First, this issue is not directly related with the regional settings in
Control Panel.

One possible cause is related to a new feature in ASP.NET 2.0.

ASP.NET 2.0 has a new feature called 'Auto-Culture Handling': it maps
Accept-Language headers to CultureInfo objects and attaches them to the
current thread, thus altering DateTime.ToShortDateString()'s result.
Auto-culture handling is enabled for individual pages by including
Culture="auto" and UICulture="auto" attributes in the pages' @ Page
directives. It's enabled site-wide by including a <globalization
culture="auto" uiCulture="auto"/> element in web.config.

When this feature is enabled, the user can configure the browser to change
the preferred language and shows different result of
DateTime.ToShortDateString().

If this is not your case, you can always override the default cultureInfo
by setting the culture and uiCulture to "en-GB" either in individual page
or in web.config.


Regards,

Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top