Posted By

adrianparr on 06/04/10


Tagged

month day year date format formatted as3 YYMMDD


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

socialflasher
PixelJuice
tspitzr


AS3 Get the Current Date in the Format YYMMDD (Reverse format)


 / Published in: ActionScript 3
 

  1. function getYYMMDD():String
  2. {
  3. var dateObj:Date = new Date();
  4. var year:String = String(dateObj.getFullYear());
  5. var month:String = String(dateObj.getMonth() + 1);
  6. if (month.length == 1) {
  7. month = "0"+month;
  8. }
  9. var date:String = String(dateObj.getDate());
  10. if (date.length == 1) {
  11. date = "0"+date;
  12. }
  13. return year.substring(2, 4)+month+date;
  14. }
  15.  
  16. trace(getYYMMDD());
  17.  
  18. // OUTPUT
  19. // 100604

Report this snippet  

You need to login to post a comment.