The following should work:
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd.MM.yyyy}", ApplyFormatInEditMode = true)]
public DateTime? ServiceCreatedFrom { get; set; }
and in your editor template:
@model DateTime?
@Html.TextBox(
string.Empty,
ViewData.TemplateInfo.FormattedModelValue,
new { @class = "date" }
)
and then:
@Html.EditorFor(x => x.ServiceCreatedFrom)
The second argument you were passing to the EditorFor call doesn't do what you think it does.
For this custom editor template, since you specified the format explicitly on your view model property the <globalization>
element in your web.config and the current thread culture will have 0 effect. The current thread culture is used with the standard templates and when you didn't override the format with the [DisplayFormat]
attribute.