A Tip on Date Class in Flex.

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: