javascriptkendo-uikendo-gridkendo-timepicker

kendo timepicker " yyyy-mm-ddThh:mm:ss.000Z" how to change hh:mm format


I am using kendo ui using time picker 24h display success but I am get it data yyyy-mm-ddThh:mm:ss 000z but I need hh:mm only. How to change it?

Get it time value :
"2018-10-07T19:30:00.000Z"

my need:
selected time only 09:10

enter image description here


Solution

  • If you wanted the timepicker to display it in HH:mm, then format is the way to go like :

    $("#timepicker").kendoTimePicker({
        format: "HH:mm"
    })
    

    but if you wanted the value to be HH:mm you need to use parseDate() and toString() like:

    console.log("formatted value " + kendo.toString(kendo.parseDate(this.value()), "HH:mm"));
    

    Working example, check console log

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8"/>
        <title>Kendo UI Snippet</title>
    
        <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.3.911/styles/kendo.common.min.css"/>
        <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.3.911/styles/kendo.rtl.min.css"/>
        <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.3.911/styles/kendo.silver.min.css"/>
        <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.3.911/styles/kendo.mobile.all.min.css"/>
    
        <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
        <script src="https://kendo.cdn.telerik.com/2018.3.911/js/kendo.all.min.js">
        <script src="https://kendo.cdn.telerik.com/2018.3.911/js/kendo.console.js"></script>
    </head>
    <body>
      
    <input id="timepicker" />
    <script>
    $("#timepicker").kendoTimePicker({
        format: "HH:mm",
      	change: function(){
    			console.log("raw value " + this.value());
          console.log("formatted value " + kendo.toString(kendo.parseDate(this.value()), "HH:mm"));
    		}
    });
    </script>
    </body>
    </html>