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


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



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.