asp.net mvc 4 - Date field is not displayed when DateFormat is dd.MM.yyyy and dd is bigger than 12 -


in view model have several datetime fields. i've decorated them displayformat attribute give them date time format:

 public class mymodel{    [displayformat(dataformatstring = "{0:dd.mm.yyyy}")]    public datetime? receiveddate{get;set;}    //omitted brevity  } 

this view:

 <div>@html.displayfor(x=>x.receiveddate)</div> 

now when date 12 july 1985, it'll display 07.12.1985 (day , month swapped). if set date example 13 july 1985 , it'll blank. apparently mvc tries match entered date other format.

p.s. first insert model database , read added model on view.

i've found problem caused issue. in web.config file, there following entry:

<system.web>   <globalization enableclientbasedculture="true" culture="auto:en-us" uiculture="auto:en-us" /> </system.web> 

so setting current culture us. after removing entry problem got solved. btw, can set desired culture instead of removing too.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -