This is a migrated thread and some comments may be shown as answers.

Kendo AngularJS kendo-date-picker: How to force FORM posting format to yyyy-MM-dd

1 Answer 629 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
IanV
Top achievements
Rank 1
Veteran
IanV asked on 30 Aug 2020, 06:54 PM

I am updating an older site running AngularJS and Kendo in Asp.Net MVC

My html Form has this control that is posted to the back end:

 

@using (Html.BeginForm( new { name = "frmMain", novalidate = "", id = "frmMain"  }))
      <input kendo-date-picker
      ng-model=".BiWeeklyStartDate"
           k-parse-formats="['yyyy-MM-dd']"
           k-format="'yyyy-MM-dd'"/></p>

The date that is posted to the backend is a full date. How can I change that so that the Kendo Control sends "yyyy-MM-dd" to the backend only?

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 01 Sep 2020, 11:56 AM

Hello Ian,

The DatePicker value can be converted to the desired one via the kendo.toString method:

var datepicker = $("#datepicker").data("kendoDatePicker");
var value = datepicker.value();
kendo.toString(value,"dd/MM/YYYY")

More information can be obtained in the following SO thread: https://stackoverflow.com/a/25286283/12355063

And a Dojo where he above is demonstrated: https://dojo.telerik.com/OKOhAgAs

Let me know if this is what you are looking for.

Regards,
Nikolay
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

Tags
Date/Time Pickers
Asked by
IanV
Top achievements
Rank 1
Veteran
Answers by
Nikolay
Telerik team
Share this question
or