0

Inside my mvc razor form I have inputbox for datetime. I'm using datetime picker plugin which allows me to enter date and time as well. I initialized this plugin script to format datetime as

$('.dateTime').datetimepicker({                
     timeFormat: "HH:mm:ss",
     dateFormat: 'dd.mm.yy',
});

Datetime property inside my model (which I use in razor form) has dataannotation to format date as

[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd.MM.yyyy HH:mm:ss}")]
public DateTime MyDateTime{ get; set; }

Inside form when I select desired date and time my text box is filled with values like

28.03.2015 09:12:00

As far as I can see this datetime format suits my model datetime format but I'm getting form js validation error

The field MyDate must be a date.

Update: Inside form I'm already getting datetime in format which I need

28.03.2015 09:12:00

and if I remove dataformat annotation from my model properties than I cannot process the form back to controller it brings up datetime window to enter datetime again?

Does anyone has solution?

user1765862
  • 13,635
  • 28
  • 115
  • 220
  • 1
    possible duplicate of [jquery ui datepicker and mvc view model type datetime](http://stackoverflow.com/questions/27285458/jquery-ui-datepicker-and-mvc-view-model-type-datetime) –  Mar 28 '15 at 08:48
  • you should have the corresponding format set in the thread.currentculture.datetimeformat – Saravanan Mar 29 '15 at 17:10

0 Answers0