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

Problem with date format

5 Answers 134 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Elliot
Top achievements
Rank 1
Elliot asked on 31 Mar 2016, 02:41 PM

I have the following date picker:

<input kendo-date-picker ng-model="incident.dateOfIncident" required k-format="'{{dateFormat}}'" k-max="today" />

The dateFormat is set to "dd-MMM-yyyy".  When I display the value of {{incident.dateOfIncident}} it is showing as:

"2016-03-09T05:00:00.000Z"

but the date picker is blank.  Why? and how do I get it to display the date in the dateFormat?

I have read on a different post about parseFormats but I cant seem to get it to work.  If I am in fact supposed to use parseFormats what format would I use?

5 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 04 Apr 2016, 10:04 AM
Hello Elliot,

The AngularJS template will not be evaluated before widget's initialization. Hence, during initialization process the format is still not defined, which will result in incorrect behavior.

You can find more details about the case here: The best solution in this case will be to use a k-options with predefined options that is coming from the model scope.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Elliot
Top achievements
Rank 1
answered on 04 Apr 2016, 02:52 PM

That doesnt seem to work unless I am doing something wrong.  Here is what I have:

<input kendo-date-picker ng-model="incident.dateOfIncident" k-options="incidentDateOptions" required />

and in the controller:

$scope.incidentDateOptions = {
    format: "dd-MMM-yyyy",
    max: new Date()
};

0
Georgi Krustev
Telerik team
answered on 06 Apr 2016, 09:04 AM
Hello Elliot,

I prepared a simple Dojo demo showing how to define the format option of the widget: Could you modify the demo showing the erroneous behavior?

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Elliot
Top achievements
Rank 1
answered on 12 Apr 2016, 06:35 PM

http://dojo.telerik.com/eXOJU/3

Essentially all I did was replace your $scope.dateString = "05-Apr-2016"; with $scope.dateString = "2016-04-13T04:00:00.000Z"; which is how the date is received from the webapi as indicated in the original post.  With this date format nothing is appearing in the date picker.l

0
Georgi Krustev
Telerik team
answered on 14 Apr 2016, 09:40 AM
Hello Elliot,

Probably, I am missing something, but the widget works as expected on my end: If the problem still persists, I would suggest you set the parseFormats option, ensuring that the provided date string can be parsed correctly:
Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Date/Time Pickers
Asked by
Elliot
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Elliot
Top achievements
Rank 1
Share this question
or