Date and Time and Days with AS3

Some useful snippets of code for dealing with the date function in Flash. Needed this stuff when using a database provided start date for a user using an application, so as to know how many days had elapsed since they’d ‘started’ so had access to new stuff.

var then:Number = Date.parse("Oct 25 2010");
var now:Number = Date.parse("Nov 2 2010");

var daysBetween:Number = Math.abs(Math.round((then-now)/86400000));

trace(daysBetween); 
var startDate:Date = new Date(2010, 9, 22); //October (months: 0-11)
var serverDate:Date = new Date(2010, 10, 3); //November (months: 0-11)
ApplicationVars.daysElapsed = Math.abs(Math.floor(Math.round((SaveData.startDate - currentDate.time) / 86400000)));
Tech Reference:

Leave a Reply

Your email address will not be published. Required fields are marked *

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑