kendo timepicker“ yyyy-mm-ddThh:mm:ss.000Z”如何更改hh:mm格式

时间:2018-10-08 17:10:52

标签: javascript kendo-ui kendo-grid kendo-timepicker

我正在使用时间选择器24h显示成功使用kendo ui,但是我得到了数据yyyy-mm-ddThh:mm:ss 000z,但是我只需要hh:mm。如何更改?

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

my need:
selected time only 09:10

enter image description here

1 个答案:

答案 0 :(得分:0)

如果您希望时间选择器以HH:mm显示,则格式是一种解决方法 就像:

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

,但是如果您希望该值为HH:mm,则需要使用parseDate()toString() 喜欢:

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

工作示例,检查控制台日志

<!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>