Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DateFormat and Culture
Message
 
To
09/03/2016 09:06:05
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
ASP.NET
Miscellaneous
Thread ID:
01632723
Message ID:
01632778
Views:
64
You can sniff the browser's languages and based on that automatically switch that local. Best to do this in Application_BeginRequest of each request.

You'll probably want to be careful not to actually support all languages for translation (UICulture), but you might want to support all the culture information (Culture) for date and number formats.

You can also override specific settings explicitly by creating a new Culture object for a specific locale and hten overriding any values. For example, I like to override the currency symbol and set it to a $ because I only sell stuff in US dollars regardless of the user's culture. Yet I allow people to see dates and
numbers in their culture specific formats.

I have a related blog post that discusses selecting cultures and overriding some values (I typically override the currency symbol because I charge in $ regardless of locale).

https://weblog.west-wind.com/posts/2014/Mar/27/Auto-Selecting-Cultures-for-Localization-in-ASPNET

All that said, for dates I much prefer NOT using numbers but using things Oct 10, 2015 or things like Yesterday, last week etc. These things are usually much better at showing the values wihtout the positioning ambiguity. Something to consider.


+++ Rick ---

>Hi,
>
>using C# and ASP.NET for a web site. When I run the stuff locally, my dates display in dd/mm/yyyy format which is what I want. When I install it on a web server which has its date formatting set to mm/dd/yyyy the web pages display dates in mm/dd/yyyy format.
>
>What I would like is the dates to display in the format set on the PC that is accessing the web site. I am using DevExpress and their advice was to use this:
>
>
        protected void Page_Load(object sender, EventArgs e)
>        {
>            (ASPxGridViewMain.Columns["Timestamp"] as GridViewDataDateColumn).PropertiesDateEdit.DisplayFormatString = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
>        }
>
>
>This doesn't seem to be working.
>
>Any suggestions as to how to get this to work?
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform