I have been having headaches with this function so I need a little help. Describing a little bit there is one class which has this attribute:
public class SessionDate
{
...
[DisplayFormat(DataFormatString = "{0:d}")]
public DateTime? searchValue2 { get; set; }
...
}
and there is a interface that has this function
public interface ISessionDate
{
IEnumerable<SessionDate> Search (string searchName, Datetime? searchDate)
}
which is declared in another class
public class SessionDateHelper
{
IEnumerable<SessionDate> Search (string searchName, Datetime? searchDate)
{
...
}
}
The problem is that the searchvalue2 is invoked in the View (inside the MVC 4 logic), which is set to dd/M/yyyy date format, but when I invoke the search in the Controller, somehow it goes rearranged to M/dd/yyyy, making the input change completely. For example I introduce 09/03/2014 (March 9th, 2014), but when it reaches the service it gets 03/09/2014 (Sept 03rd, 2014), how can I set that the function in the Interface and Helper automatically sets the date to {0:d}