How to Compare Two Dates in AS3
Posted by robert | Filed under ActionScript 3
var daysApart = getDaysBetweenDates(new Date(), new Date(2011, 1, 11)) trace(daysApart); function getDaysBetweenDates(date1:Date,date2:Date):int { var oneDay:Number = 1000 * 60 * 60 * 24; var date1Milliseconds:Number = date1.getTime(); var date2Milliseconds:Number = date2.getTime(); var differenceMilliseconds:Number = Math.abs(date1Milliseconds - date2Milliseconds); return Math.round(differenceMilliseconds/oneDay); }
July 9, 2011 at 6:31 pm
This was super useful!!! thanks :D
April 22, 2014 at 10:09 am
Thanks!!! :)
November 10, 2014 at 12:09 pm
Great!
Thank you so much!