How to default kendo datetimepicker 12:00AM value

2 posts, 0 answers
  1. Frank
    Frank avatar
    95 posts
    Member since:
    Mar 2012

    Posted 13 Jan Link to this post

    I have a datetimepicker. 

     

    <div class="EditLabel">
                                                    <label for="DueDate" class="control-label">Due Date</label>
                                                    <input kendo-date-time-picker k-onkeyup="'yyyy-MM-dd hh:mmtt'" k-format="'yyyy-MM-dd hh:mmtt'" k-options="dateTimePickerOptions"
                                                           id="picker" ng-bind="DueDate" k-ng-model="DueDate" ng-model="MarketingItem.DueDate" class="form-control input-sm" />
    </div>

     $scope.dateTimePickerOptions = {
            format: "MM/dd/yyyy hh:mmtt"
        }

    when user selects a date, i want to default the time to be 5:00PM instead of 12:00AM. if the user selects a different time, i want the value to be set accordingly. 

    Can you please tell me how i can accomplish that? I am using angular 1. thanks.

     

  2. Stefan
    Admin
    Stefan avatar
    1018 posts

    Posted 17 Jan Link to this post

    Hello Frank,

    The desired result can be achieved using a custom approach on the change event to check if a new date is selected and then set the time to 05:00 PM.

    I can suggest using the open event of the widget to take the current value than on the change event to check if the date is changed. If the date is changed, manually set the time to 05:00 PM using the value method:

    http://docs.telerik.com/kendo-ui/api/javascript/ui/datetimepicker#events-open

    http://docs.telerik.com/kendo-ui/api/javascript/ui/datetimepicker#events-change

    http://docs.telerik.com/kendo-ui/api/javascript/ui/datetimepicker#methods-value

    I hope this will help to achieve the desired result.

    Regards,
    Stefan
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top