KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm using the following code // Model [DisplayFormat( ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")] public DateTime StartDate { get; set; } // View @Html.EditorFor(model => model.StartDate) to format the StartDate but the result is xx-xx-xxxx instead of xx/xx/xxxx . How can I solve this and always use the xx/xx/xxxx format? UPDATE: Changing the culture to en-US seems to work: var culture = new CultureInfo(userCulture); System.Threading.Thread.CurrentThread.CurrentCulture = "en-US"; System.Threading.Thread.CurrentThread.CurrentUICulture = "en-US"; but this is not a solution because I may be using a different culture and I still want to show the date in a different way. If the current culture tells that the date should display dd-MM-yyyy then using DisplayFormat as above has no effect and the dates do not display like dd/MM/yyyy .
Tags (comma-separated)
Save Edits
Cancel