在Flex中的最后15分钟的周期 [英] Round Date to nearest 15 minute interval in Flex
本文介绍了在Flex中的最后15分钟的周期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有谁知道这可能是如何实现的,或者是跨越一个代码snippit这将使我在正确的轨道?
解决方案
尝试这个
var date:Date = new Date();
var min:Number = date.minutes;
var h:Number = date.hours;
min = min +(15 - min%15);
h + = min / 60;
min = min%60;
date.hours = h;
date.minutes = min;
trace(date.toTimeString());
I am building a control to allow me to set a meeting time, and I would like it to use as a default, the current time rounded up to the nearest 15 minute interval. So if it is currently 6:07, it would read 6:15 as the start time.
Does anyone know how this might be accomplished, or have run across a code snippit that would put me on the right track?
解决方案
Try this
var date:Date = new Date();
var min:Number = date.minutes;
var h:Number = date.hours;
min = min + (15 - min % 15);
h += min / 60;
min = min % 60;
date.hours = h;
date.minutes = min;
trace(date.toTimeString());
这篇关于在Flex中的最后15分钟的周期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文