# \[ MX \] Time controlling RGB ( Day + Night )

**URL:** <https://forum.kirupa.com/t/mx-time-controlling-rgb-day-night/92410>\
**Category:** Uncategorized\
**Created:** [October 16, 2003, 8:54pm UTC](https://forum.kirupa.com/t/mx-time-controlling-rgb-day-night/92410 "2003-10-16T20:54:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flash\_freak](https://avatars.discourse-cdn.com/v4/letter/f/47e85d/32.png) [@flash\_freak](https://forum.kirupa.com/u/flash_freak)\
**Post date:** [October 16, 2003, 8:54pm UTC](https://forum.kirupa.com/t/mx-time-controlling-rgb-day-night/92410/1 "2003-10-16T20:54:45Z")

</div>

I’m trying to control a clip’s darkness and brightness by the current time of day. I don’t want to use a dozen or so if ( theTime == ) statements if I can really help it. This is what I have so far

function pictureClock()

{   
var now = new Date ();  
var dayPercent = ( now.getHours() \> 12 ? now.getHours() - 12 : now.getHours()) / 24;  
var hourPercent = now.getMinutes() / 60;  
var minutePercent = now.getSeconds() / 60;

```
            hourHand_mc._rotation = 360 * dayPercent + hourPercent * ( 360 / 24 );
minuteHand_mc._rotation = 360 * hourPercent;
secondHand_mc._rotation = 360 * minutePercent;

var brightness = new Color(skyline);
var brightnessTransform = new Object();
var brightnessAmount = 0 - ( 360 * minutePercent );

            brightnessTransform.rb = brightnessAmount;
brightnessTransform.bb = brightnessAmount;
brightnessTransform.gb = brightnessAmount;
brightness.setTransform( brightnessTransform );

updateAfterEvent();

```

}

setInterval( pictureClock, 100 );

At the moment it fades to Night but does not fade back to Day, it suddenly jumps back to 0 at 12 noon. Any advice would be muchly appreciated 🙂

Thanks
