Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Help modifying a clock code in flash CS6.

New Here ,
Sep 09, 2013 Sep 09, 2013

I have a flash file that has a built in clock.  I would like the clock to function on a 12 hour schedule instead of a 24 hour or military one. 


Any help would be greatly appreciated! 

Here is the code:

onClipEvent (enterFrame) {

                 now = new Date();

switch (now.getMonth()) {

                case 0:

                month = "January";

    break;

  case 1:

    month = "February";

    break;

  case 2:

    month = "March";

    break;

  case 3:

    month = "April";

    break;

  case 4:

    month = "May";

    break;

  case 5:

    month = "June";

    break;

  case 6:

    month = "July";

    break;

  case 7:

    month = "August";

    break;

  case 8:

    month = "September";

    break;

  case 9:

    month = "October";

    break;

  case 10:

    month = "November";

    break;

  case 11:

    month = "December";

    break;

  default:

    trace ("")

}

switch (now.getDay()) {

                case 0:

                day = "Sunday";

    break;

  case 1:

    day = "Monday";

    break;

  case 2:

    day = "Tuesday";

    break;

  case 3:

    day = "Wednesday";

    break;

  case 4:

    day = "Thursday";

    break;

  case 5:

    day = "Friday";

    break;

  case 6:

    day = "Saturday";

    break;

  default:

    trace ("")

}

minutes = now.getMinutes();

if (minutes <=9 && minutes >=0)

{

                minutes = "0"+now.getMinutes();

}

seconds = now.getSeconds();

if (seconds <=9 && seconds >=0)

{

                seconds = "0"+now.getSeconds();

}

date1 =day  +","+ month +","+ now.getDate();

date2 =now.getHours() + ":" + minutes;

}

Thanks!

TOPICS
ActionScript
626
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 09, 2013 Sep 09, 2013

Replace:

date2 =now.getHours() + ":" + minutes;

With:

var hour = now.getHours();

if(hour == 0){
     hour = 12
} else if(hour > 12){
     hour -= 12
}

date2 =hour + ":" + minutes;

Translate
LEGEND ,
Sep 09, 2013 Sep 09, 2013
LATEST

Replace:

date2 =now.getHours() + ":" + minutes;

With:

var hour = now.getHours();

if(hour == 0){
     hour = 12
} else if(hour > 12){
     hour -= 12
}

date2 =hour + ":" + minutes;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines