datetime在日期时间选择器MVC4中无效

时间:2013-07-15 10:17:43

标签: jquery asp.net-mvc-4 razor

我们在下面的jQuery日期时间选择器中以mvc视图显示日期。

$.widget("df.datetime", $.df.datetimecontrols, {
    _createInput: function ()
    {
        var min = this.element.attr("data-minRelDate"),
            max = this.element.attr("data-maxRelDate");

        this._Input = $("<input>")
            .addClass("datetime")
            .attr("disabled", this._getDisableProp() ? "disabled" : "")
            .prop("disabled", this._getDisableProp() ? true : false)
            .addClass(this._getDisableProp() ? "disabled" : "")
            .datetimepicker({
                numberOfMonths: 2,
                minDate: min,
                maxDate: max,
                //Uncomment below line for date format.
                //dateFormat: $.datepicker.RFC_1123,
                timeText: "Current time:",
                hourGrid: 2,
                minuteGrid: 5,
                timeFormat: "hh:mm TT",
                onSelect: $.proxy(this._change, this),
                beforeShow: $.proxy(this._focusHndlr, this, 4),
                onClose: $.proxy(this._focusHndlr, this, -4)
                //TimeZone is not supported Across the browsers.To do manually there will change in the 
                //  years(save light day etc.,) https://github.com/timrwood/moment/issues/162
            })
            .focus($.proxy(this._inputFocus, this))
            .blur($.proxy(this._inputBlur, this))
            .appendTo(this._Wrapper);

        //Base element value to be widgets value.
        if ($(this.element).val() != "") {
            // If we wont specify time on recreate then time sliders will stay unchanged.
            //  we manipulate datepicker value and value of input to display differently.
            //  LLLL--> Thursday, April 18 2013 1:20 PM
            //  L --> 04/18/2013
            //  LT --> 8:30 PM
           this._Input.datepicker("setDate", new Date(moment($(this.element).val()).format("LLLL")));
           this._Input.val(moment($(this.element).val()).format("L LT"));
        }
    },

我的编辑器模板是:

<input data-val="true" id="FromDate" type="datetime" class="datetime" data-datetime-in="utc" data-datetime="" value ="@Model" />

问题是当我最终在视图中显示日期时显示错误。

例如:我在DB中的日期为“2015-02-27 00:00:00 +05:30”

它显示为“03/02/2017 12:00 AM”

有人可以告诉我这里有什么问题吗?

0 个答案:

没有答案