# Controlling time of day to sync to image

**URL:** <https://forum.kirupa.com/t/controlling-time-of-day-to-sync-to-image/156136>\
**Category:** flash\
**Created:** [July 22, 2005, 8:50pm UTC](https://forum.kirupa.com/t/controlling-time-of-day-to-sync-to-image/156136 "2005-07-22T20:50:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fiCti0naL](https://avatars.discourse-cdn.com/v4/letter/f/8491ac/32.png) [@fiCti0naL](https://forum.kirupa.com/u/fiCti0naL)\
**Post date:** [July 22, 2005, 8:50pm UTC](https://forum.kirupa.com/t/controlling-time-of-day-to-sync-to-image/156136/1 "2005-07-22T20:50:12Z")

</div>

Im building a flash movie that will have a image of a building that changes according to the time of day. I’m close to getting it figured out, I just cant exactly figure out which variables to use to tell it when to go to the specific frame the new time of day image is.

```auto
onClipEvent (enterFrame) {
    myTime = new Date();
    nSeconds = myTime.getSeconds();
    nMinutes = myTime.getMinutes();
    nHours = myTime.getHours();
    if (nHours>=12) {
        ampm = "pm";
    } else {
        ampm = "am";
    }
    if (nHours>=13) {
        nHours = nHours-12;
    }
    if (length(nMinutes) == 1) {
        nMinutes = "0"+nMinutes;
    }
    if (length(nSeconds) == 1) {
        nSeconds = "0"+nSeconds;
    }    
    nTime = nHours+":"+nMinutes+":"+nSeconds+" "+ampm;
    
}

```

I’ve managed to get it to switch if I set it to just a number by just adding:

```auto

if (nHours>=1) {
         _root.day.gotoandPlay("day")
     } else {
        _root.day.gotoandPlay("night")

```

How exactly can I tell it to go according to 7am-8pm and 8pm-7am? Once I figure this part out I’ll be able to start adding in more images and detailed times of day, and possibly integrate weather etc in the future.

Thanks for any help.
