设置发送到控制器的 Kendo DateTimePicker 日期格式 [英] Set the format of a Kendo DateTimePicker date sent to the controller
问题描述
我在我的应用程序中使用了 Kendo DateTimePicker.
I'm using a Kendo DateTimePicker in my application.
我在我的应用程序中从中得到的价值是
The value I get from it in my application is
Wed Aug 13 2014 00:00:00 GMT+0200 (Romance Daylight Time)
我无法将其解析为 DateTime.我收到字符串未被识别为有效日期时间"的消息.错误.
I can't parse this to a DateTime. I get a "String was not recognized as a valid DateTime." error.
如何设置从 DateTimePicker 获取的日期格式?Kendo DateTimePicker 中是否有选项?t
How can I set the format of the date I get from the DateTimePicker?? Is there an option in Kendo DateTimePicker??t
推荐答案
如果您需要更改从您的应用程序中获得的日期,您可以执行以下操作
If you Need to Change the Date that you get from your application you can do as below
var dateobj=kendo.parseDate("Wed Aug 13 2014 00:00:00 GMT+0200 (Romance Daylight Time)", "yyyy-MM-dd h:mm:ss tt");
var datestring = kendo.toString(dateobj, "MM-dd-yyyy h:mm:ss tt");
kendo.parseDate()
将日期解析为日期对象,kendo.toString()
将日期格式化为字符串
kendo.parseDate()
will Parse the Date to a Date Object and kendo.toString()
will format the date to a string
如果您需要转换从 Datepicker 获得的日期,请执行此操作
If you need to convert the date you get from the Datepicker Do this
var datepicker = $("#datepicker").data("kendoDatePicker");
var value = datepicker.value();
kendo.toString(value,"dd/MM/YYYY")
如果您需要将 Datepicker 日期转换为 Sever Date
IF you need to convert Datepicker date to the Sever Date
var datepicker = $("#datepicker").data("kendoDatePicker");
var value = datepicker.value();
value.toUTCString();
这篇关于设置发送到控制器的 Kendo DateTimePicker 日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!