如何获取12小时格式的extjs getHours()值当前获取24小时格式的小时值
您可以使用课堂获取12小时格式 以下是一些格式:-如何获取12小时格式的extjs getHours()值当前获取24小时格式的小时值,extjs,Extjs,您可以使用课堂获取12小时格式 以下是一些格式:- g12小时格式,一小时不带前导零1到12 i分钟,前导零为00到59 a美林前和美林后am或pm小写字母 A大写的前梅里迪姆和后梅里迪姆AM或PM 我已经创建了一个演示它是如何工作的。希望这能帮助你解决你的问题 Ext.application({ name: 'Fiddle', launch: function () { var t1 = Ext.create('Ext.form.field.Time', {
Ext.application({
name: 'Fiddle',
launch: function () {
var t1 = Ext.create('Ext.form.field.Time', {
xtype: 'timefield',
name: 'in',
fieldLabel: 'Time In',
minValue: '6:00 AM',
maxValue: '8:00 PM',
increment: 60,
renderTo: Ext.getBody()
});
var time = Ext.Date.add(new Date(), Ext.Date.HOUR, + 14).getHours(); //getting hour values in 24 format want in 12 hours format
t1.setMaxValue(time); //unable to setMaxValue
}
});
这是您的第十一个问题,其他人必须在每个问题中重新格式化您的代码,你对改变这一点没有兴趣…这是什么版本的ExtJs?是否需要将ExtJs中的当前GMT+14时间传递到时间域?你想从当前时间开始接下来的14个小时吗?不,我需要将此链接中的当前GMT+14时间传递到我的时间域请查看我已根据此处更新了我的答案
Ext.create('Ext.form.Panel', {
title: 'Time Card',
width: 300,
bodyPadding: 10,
renderTo: Ext.getBody(),
defaults: {
xtype: 'timefield',
minValue: '6:00 AM',
maxValue: '8:00 PM',
increment: 30,
anchor: '100%',
listeners: {
change: function (timefield, newValue) {
Ext.Msg.alert('Succes', 'Good you have selected <b>' + Ext.Date.format(newValue, 'g:i A') + '</b>');
}
}
},
items: [{
name: 'in',
fieldLabel: 'Time In'
}, {
name: 'out',
fieldLabel: 'Time Out'
}, {
xtype: 'button',
text: 'Get current GMT+14 Time',
handler: function () {
var date = new Date(),
dateGmtPlus14 = new Date(date.valueOf() + date.getTimezoneOffset() * 60000); //Multiply this by 60,000 (milliseconds in a minute) to get the milliseconds and subtract from the date to create a new date
Ext.Msg.alert('Succes', 'Current time with GMT+14 is <br> 12 hours format : <b>' + Ext.Date.format(dateGmtPlus14, 'g:i:s A') +
'</b><br>24 hours format: <b> ' + Ext.Date.format(dateGmtPlus14, 'G:i:s') + '</b>');
}
}]
});
new Date(date.valueOf() + date.getTimezoneOffset() * 60000)