我将日期作为以下格式的字符串:
string s = "Thu Aug 22 00:00:00 UTC+0530 2013";
我必须将其转换为DatetimeOffset
我使用过Parse
的 ,ExactParse
方法。但是,我似乎无法正确理解。我遇到了String was not in correct format
例外。
我必须将上述值作为datetimeoff
对象存储在数据库中。
防爆输出:2013-08-22 00:00:00 +05:30.
从 jQuery 呈现的日期:
$.widget("df.datetime", $.df.datetimecontrols, {
_createInput: function () {
var min = this.element.attr("data-minRelDate"),
max = this.element.attr("data-maxRelDate");
debugger;
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"));
}
},