2017-04-20 45 views
0

你好有我想转换2017年3月4日上午12:00至2017年12月1日12:00:00 我怎么能做到这一点在Ext JS中 目前我的代码是:日期时间转换或煎茶

this.ToDatePicker = Ext.create('Ext.form.field.Text', { 
     xtype: 'textfield', 
     name: 'name', 
     labelAlign: 'top', 
     fieldLabel: 'Date Time', 
     value: Ext.Date.format(new Date(), "d-m-Y h:iA"), 
     listeners: { 
      scope: this, 
      afterrender: function (c) { 
       c.getEl().on('click', function (e) { 
        console.log(e.target) 
        NewCssCal_DisableAfterToday(Ext.get(e.target).dom.id, 'ddmmyyyy', 'dropdown', true, 12) 
       }); 
      } 
     } 
    }); 

this.ToCalenderIcon = new Ext.Container({ 
     html: "<img class='calIcons' src='public/touchWorldCssJs/images/cal.gif'/>", 
     scope: this, 
     padding: '27 5 5 5', 
     listeners: { 
      scope: this, 
      afterrender: function (c) { 
       c.getEl().on('click', function (e) { 
        if (Ext.get(e.target).hasCls('calIcons')) { 
         console.log(Ext.get(e.target).dom.id); 
         NewCssCal_DisableAfterToday(me.ToDatePicker.inputEl.id, 'ddmmyyyy', 'dropdown', true, 12) 
        } 
       }); 
      } 
     } 
    }); 

this.ToCalenderIcon渲染这套日期甲像2017年3月4日上午12:00后,所以我需要将其转换为2017年12月1日12:00:00

+0

我没有得到你的问题。你想将今天的日期转换为“2017-12-01 12:00:00”格式或你给了什么? –

回答

1

的AM/PM概念不被JavaSc支持RIPT本身据我所知,所以你必须根据通过Ext.Date指定的格式做了解析。

在你toDatePicker,您明确格式的日期是 “d-M-Y H:IA”。 要获得回你需要先分析它不同的格式(如JavaScript的原生日期无法解析生成的字符串):

Ext.Date.format(Ext.Date.parse("03-04-2017 12:00AM", "d-m-Y h:iA"), "d-m-Y h:i:s") 

我希望这就是你要找的人。 如果你有兴趣,而不是如何让四月的第三个看起来像第一个12月,你应该只写月1日在第一位。

+0

谢谢你......它的工作。 –