Use custom formatting to display any date as MM/DD/YYYY : Date format : Development Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Development » Date format »

 

Use custom formatting to display any date as MM/DD/YYYY


 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){


    }
     function dateToMMDDYYYY(aDate:Date):String {
         var SEPARATOR:String = "/";
    
         var mm:String = (aDate.month + 1).toString();
         if (mm.length < 2mm = "0" + mm;
    
         var dd:String = aDate.date.toString();
         if (dd.length < 2dd = "0" + dd;
    
         var yyyy:String = aDate.fullYear.toString();
         return mm + SEPARATOR + dd + SEPARATOR + yyyy;
     }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Development
» Date format