# Using getHours to control a movie clip

**URL:** <https://forum.kirupa.com/t/using-gethours-to-control-a-movie-clip/226402>\
**Category:** Uncategorized\
**Created:** [May 21, 2007, 7:04am UTC](https://forum.kirupa.com/t/using-gethours-to-control-a-movie-clip/226402 "2007-05-21T07:04:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![visualmonk](https://avatars.discourse-cdn.com/v4/letter/v/e495f1/32.png) [@visualmonk](https://forum.kirupa.com/u/visualmonk)\
**Post date:** [May 21, 2007, 7:04am UTC](https://forum.kirupa.com/t/using-gethours-to-control-a-movie-clip/226402/1 "2007-05-21T07:04:19Z")

</div>

Hey guys,

I have a movie clip that animates across a set of labels that are based on a 24hour day. The hours are separated into blocks and the basic idea is to mimic a pda style daily calendar based on the current hour. The day starts at 6am and ends at 9pm.

This is the code i have but doesnt seem to be working correctly, im not sure i have it right here but im thinking the “AM, PM” thing is messing it up…

var myCal:Date = new Date();  
var myMinutes:Number = myCal.getMinutes()  
var myHours:Number = myCal.getHours()  
var myTime:String

if (myHours \> 12) {  
myTime = “PM”;  
} else if (myHours == 12) {  
myTime = “PM”;  
} else {  
myTime = “AM”;  
}  
if (myHours \> 23){  
myHours = myHours + 1;  
}

if ((myHours \<= 6) && (myTime == “AM”)){  
gotoAndPlay(“six”);  
}  
else if ((myHours \>= 6) && (myTime == “AM”)){  
gotoAndPlay(“one”);  
}  
else if ((myHours \>= 9) && (myTime == “AM”)){  
gotoAndPlay(“two”);  
}  
else if ((myHours \>= 12) && (myTime == “AM”)){  
gotoAndPlay(“three”);  
}  
else if ((myHours \>= 15) && (myTime == “PM”)){  
gotoAndPlay(“four”);  
}  
else if ((myHours \>= 18) && (myTime == “PM”)){  
gotoAndPlay(“five”);  
}  
else if ((myHours \>= 21) && (myTime == “PM”)){  
gotoAndPlay(“six”);  
}

Thanks to anyone who can help!
