我正在尝试创建一个 datetimepicker,它必须显示如下所示的日期,使用 trntrichardson 插件来使用 datetimepicker。
2013 年 4 月 2 日星期二 12:00 AM IST
我有以下代码,其中我将 UTC 时间存储为值并在文本中显示本地时间。但我无法添加本地时区缩写,如 IST、CST 等,如上面的日期所示。
请问有什么办法可以完成这项工作..我正在使用时刻插件来转换UTC和当地时间。
_createDateTime: function () {
var min = this.element.attr("data-minRelDate"),
max = this.element.attr("data-maxRelDate");
this._Input = $("<input>")
.addClass("datetime")
.datetimepicker({
numberOfMonths: 2,
minDate: min,
maxDate: max,
dateFormat: $.datepicker.RFC_1123,
hourGrid: 2,
minuteGrid: 5,
timeFormat: "hh:mm TT z",
showTimeZone: true,
onSelect: $.proxy(this._change, this)
})
.appendTo(this._Wrapper);
_change: function(){
var val = this._Input.datepicker("getDate");
//var test = moment(val).format();
//UTC to store value in server.
this.element
.attr("data-datetime", moment.utc(val)
.format("LLLL"));
//LocalTime To display.
this._Input.datepicker("setDate", new Date(moment(val).format("LLLL")));
}
我已经转换为当地时间并给了 datetimepicker taht 日期,我需要做的就是在日期字符串中添加时区缩写....任何解决方法请...