AndroidBegginer
AndroidBegginer

Reputation: 39

DateFormat DateTime Issue

I have a strange issue with my project:

While using the same MSSQL Database, my local version shows date like this:

enter image description here

And my web version shows like this:

enter image description here

Moreover, when I'm trying to edit, in my local version the "datepicker" is populated by my model.date, and on the web version.. not.

 @Html.EditorFor(model => model.StartDate, new { htmlAttributes = new { @class = "form-control" } })\

Here's part of viewmodel:

[DataType(DataType.Date)]
[DisplayName("Data od")]
public DateTime? StartDate { get; set; }

I assume its because of that different Date format. How can I approach this issue?

Upvotes: 0

Views: 22

Answers (1)

hekta
hekta

Reputation: 126

Add new Data Annotation to StartDate property

[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd}")]

Upvotes: 1

Related Questions