Get difference between two dates in days


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. public static function getDaysBetweenDates(date1:Date,date2:Date):int
  2. {
  3. var one_day:Number = 1000 * 60 * 60 * 24
  4. var date1_ms:Number = date1.getTime();
  5. var date2_ms:Number = date2.getTime();
  6. var difference_ms:Number = Math.abs(date1_ms - date2_ms)
  7. return Math.round(difference_ms/one_day);
  8. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.