c# - Date formate change when post to controller -
i want 31-12-2015 date formate controller. in case when try post date view contoller time in debug mode show me mm-dd-yyyy(12-31-2015) how formate.
e.g when enter below date
1) 12-30-2016 controller
2) 30-12-2016 dont date controller.
model
[required(errormessage = "enter date")] [displayname("payment date")] [datatype(datatype.date)] [displayformat(dataformatstring = "{0:dd/mm/yyyy}")] public datetime date { get; set; }
view
@html.textboxfor(model => model.date,new { @class = "k-input datepickerbootstrap", @required = "required", @id = "date", @name = "date" })
javascript
$('.datepickerbootstrap').datepicker({ autoclose: true, format: 'dd-mm-yyyy', });
most using en-us
culture uses mm/dd/yyyy
date format. need change server culture 1 uses dd/mm/yyyy
format (for example en-gb
)
you may through web config:
<configuration> <system.web> <globalization uiculture="en-gb" culture="en-gb" /> </system.web> </configuration>
edit
as stephen pointed out in comment format used in datepicker configuration has match format defined server culture if take en-gb
culture example since it's date format dd/mm/yyyy
, datepicker format has same:
$('.datepickerbootstrap').datepicker({ autoclose: true, format: 'dd/mm/yyyy', });
Comments
Post a Comment