Revision: 16033
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 23, 2009 18:44 by arpit
Initial Code
private function formatDate(d:Date):String
{
var now:Date = new Date();
var diff:Number = (now.time - d.time) / 1000; // convert to seconds
if (diff < 60) // just posted
{
return "Just posted";
}
else if (diff < 3600) // n minutes ago
{
return (Math.round(diff / 60) + " minutes ago");
}
else if (diff < 86400) // n hours ago
{
return (Math.round(diff / 3600) + " hours ago");
}
else // n days ago
{
return (Math.round(diff / 86400) + " days ago");
}
}
Initial URL
http://blogs.adobe.com/cantrell/archives/2009/06/actionscript-fu.html
Initial Description
Initial Title
ActionScript function for turning a date into a time interval
Initial Tags
date
Initial Language
ActionScript 3