Get current culture

Vote:
 

Hi,

I have a site in english and I want to show the dateformat based on culture e.g. en-US (mm/dd/yyyy) and en-GB (dd/mm/yyyy) how can I get this information in EPiServer?

The user is not logged in at this point.

Cheers

Ian

#24960
Oct 08, 2008 17:58
Vote:
 

One way to do it is in codebehind, here is a simple example, storing the date in "theDate" :-)

string currentCulture = EPiServer.Globalization.GlobalizationSettings.CultureLanguageCode; // fetch the current culture

EPiServer.Globalization.ContentLanguage.Instance.SetCulture("en-US"); // set the culture

string theDate = CurrentPage.Changed.ToShortDateString(); // grab the date

EPiServer.Globalization.ContentLanguage.Instance.SetCulture(currentCulture); // reset culture again

#24982
Edited, Oct 08, 2008 19:01
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.