var now:Date = new Date();
this.endDateId.selectedDate = now;//截止日期
var mon:Number = now.getMonth();
now.setMonth(mon-1);
this.begDateId.selectedDate = now;//开始日期
flex 页面显示日期,年月日都可以加减运算,从而轻松展示几天之前,或者几年,几月之间的日期。
效果如下图所示:
[img]http://dl2.iteye.com/upload/attachment/0084/9055/f6b8f23b-6e84-3afe-8a19-db849ef45f58.jpg[/img]
PS: 使用 DateField.dateToString(now, "YYYYMMDD");转换日期格式时,format参数[color=red][b]"YYYYMMDD" 一定要大写[/b][/color]才会有效果。
this.endDateId.selectedDate = now;//截止日期
var mon:Number = now.getMonth();
now.setMonth(mon-1);
this.begDateId.selectedDate = now;//开始日期
flex 页面显示日期,年月日都可以加减运算,从而轻松展示几天之前,或者几年,几月之间的日期。
效果如下图所示:
[img]http://dl2.iteye.com/upload/attachment/0084/9055/f6b8f23b-6e84-3afe-8a19-db849ef45f58.jpg[/img]
PS: 使用 DateField.dateToString(now, "YYYYMMDD");转换日期格式时,format参数[color=red][b]"YYYYMMDD" 一定要大写[/b][/color]才会有效果。
灵活展示日期的前端开发技巧
本文介绍如何在前端页面中灵活展示日期,包括获取当前日期、设置开始和结束日期,以及日期格式转换等关键操作。通过实例演示,展示了如何使用DateField.dateToString方法将日期格式化为'YYYYMMDD'格式,强调了参数格式的重要性。
6155

被折叠的 条评论
为什么被折叠?



