设置发送给控制器的Kendo DateTimePicker日期的格式 [英] Set the format of a Kendo DateTimePicker date sent to the controller

查看:216
本文介绍了设置发送给控制器的Kendo DateTimePicker日期的格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序中使用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。我得到一个字符串未被识别为有效的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日期转换为服务器日期

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆