A Tip on Date Class in Flex.

March 26, 2009

When you come across a Class and explore it, you should be really concentrating on the very basics of that Class first.So here I am talking about the Date Class.You can create Date Objects in four different ways.So explore about that, then you should be able to answer this question How to find the number of days betweeen two Date’s in Flex ?

Solution:

private const MS_PER_DAY:uint = 1000 * 60 * 60 * 24;

var strd1:Date=new Date(2009,2,18);
var strd2:Date=new Date(2009,2+1,18);
var tempDate:Date = new Date(strd2.time – strd1.time);

trace(‘No. of Days:’+tempDate.time/MS_PER_DAY);

Enjoy the post.