Topic: Date-picker jquery creates wrong year and format ASP.Net Core
vonmonckl free asked 5 years ago
I use a the material date-picker with default values. However, a) the format shown adds time ('0:00:00') and the supplied date (e.g. 26 September 2019) shows up as 26 december 2018??.
The HTML code is:
<div class="md-form">
<input asp-for="TodoStartDate" placeholder="Selected date" type="text" class="form-control datepicker">
<label asp-for="TodoStartDate"></label>
</div>
The Model of TodoStartDate is:
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd-MM-yyyy}")]
[Display(Name = "Start")]
public DateTime TodoStartDate { get; set; }
Screenshots
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Status
Opened
Specification of the issue
- ForumUser: Free
- Premium support: No
- Technology: MDB jQuery
- MDB Version: 4.8.10
- Device: Desktop
- Browser: Edge, Chrome
- OS: Windows10
- Provided sample code: No
- Provided link: No
MDBootstrap staff commented 5 years ago
Hi, please generate snippet with your usage of this component. I will try to modify your code to work properly.
https://mdbootstrap.com/snippets
Best Regards, Piotr
vonmonckl free commented 5 years ago
I just made a snippet, but it is hard to reproduce the error, as it needs the .Net Core environment as well to read the Date. The Snippet is can be found here: https://mdbootstrap.com/snippets/jquery/vonmonckl/1239939/
MDBootstrap staff commented 5 years ago
In the snippet, I can not test it. I obviously understand why. Well, It has to be a problem with the way you post data to the input with the date picker. Are you sure the data you are trying to send is in the proper format? I think that there is everything working fine with our component. It has to be an issue with the setup which currently I can not test. I am not sure how can I help you there. If you want to set the value of the date picker on the start of initialization simply read this part of the documentation: https://mdbootstrap.com/docs/jquery/forms/date-picker/#pre-fill-values