AS3 Code Snippet: creating date objects between start and end date with AS3

AS3 Code Snippet: creating date objects between start and end date with AS3

Quick code snippet: creating an array of all the dates between a given start and end date

In this quick code snippet we will show you how you can effectively create a Array of date objects between a given start and end date.
This can come in handy when you want to do date calculations, or have a reference to all the possible dates between start and end date range.

This AS3 snippet will effectively perform a calculation and return a nice array with a chronological list of date object!

private function getDateArray(start:Date, end:Date):Array {
    var result:Array = new Array();
    var iter:Date = new Date(start);
    while (iter <= end)
    {
        result.push(new Date(iter));
        iter.setDate(iter.getDate() + 1);
    }
    return result;
}

More interesting ActionScript code snippets? Have a look in our Creative-Geeks ActionScript 3 category


About the Author

Daan is a Creative-Geek who loves learning and sharing new techniques! Follow him on Twitter to keep up to date with the Creative-Geeks blog and other subjects. Contact him on e-mail : info[at]creative-geeks.com.