Static function for handling dates from db and converting them into readable strings. Note that days & months are 0-indexed.
Usage: var d = DateUtils.dateFromDB("2006-06-01 12:10:45"); trace(DateUtils.days[d.getDay()] + ", " + DateUtils.months[d.getMonth()] + " " + d.getDate() + ", " + (d.getHours()%12) + ":" + DateUtils.padTime(d.getMinutes()) + ((d.getHours() > 12) ? "pm" :"am"));
static public months:Array [Read Only]
static public shortmonths:Array [Read Only]
static public days:Array [Read Only]
static public shortdays:Array [Read Only]
static public function getMonth(n:Number):String
Get the month name by month number.
n | (Number) |
String
Usage: trace(DateUtils.getMonth(0); // returns "January"
static public function getShortMonth(n:Number):String
Get the short month name by month number.
n | (Number) |
String
Usage: trace(DateUtils.getShortMonth(0); // returns "Jan"
static public function getDay(n:Number):String
Get the day name by day number.
n | (Number) |
String
Usage: trace(DateUtils.getDay(0); // returns "Sunday"
static public function getShortDay(n:Number):String
Get the short day name by day number.
n | (Number) |
String
Usage: trace(DateUtils.getShortDay(0); // returns "Sun"
static public function padTime(n:Number):String
Pads hours, Minutes or Seconds with a leading 0, 12:01 doesn't end up 12:1
n | (Number) |
String
static public function dateFromDB(dbdate:String):Date
converts a DB formatted date string into a Flash Date Object.
Date
static public function getHoursAmPm(hour24:Number):Object
Takes 24hr hours and converts to 12 hour with am/pm.
hour24 | (Number) |
Object
static public function dateDiff(d1:Date, d2:Date):Number
Get the differences between two Dates in milliseconds.
d1 | (Date) |
d2 | (Date) optional [default: now] |
Number - difference between two dates in ms
static public function isValidAge(year:Number, month:Number, day:Number, requiredAge:Number):Boolean
Check if birthdate entered meets required age.
year | (Number) |
month | (Number) |
day | (Number) |
requiredAge | (Number) |
Boolean
static public function isValidDate(year:Number, month:Number, day:Number, mustBeInPast:Boolean):Boolean
Check if a valid date can be created with inputs.
year | (Number) |
month | (Number) |
day | (Number) |
mustBeInPast | (Boolean) |
Boolean