Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

Get current culture



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.



Oct 08, 2008 17:58

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

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.